A
ahrimen
Hi, First I'll state my over all goal = a text based game with several
rooms that have several exits as my first real program that I've done
without the help of a book.
I can make a normal vector object out of a custom class, I can even use
a single object of a class that has vector data members, but If my
vector object of a custom class has a vector data member my program
crashs not when I instaitant it, but if I try calling any of the member
functions, heres the code:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class CMine
{
private:
string m_yo;
vector<string> m_var;
public:
CMine(string yo = "Hello.") : m_yo(yo){m_var[0]=m_yo;}
void Show(){ cout << m_var[0] << endl; }
};
int main()
{
vector<CMine> test;
test[0].Show();
system("pause");
return 0;
}
very basic stuff, but i just dont get what i'm doing wrong or if this
is even possible.
Thanks in advace
rooms that have several exits as my first real program that I've done
without the help of a book.
I can make a normal vector object out of a custom class, I can even use
a single object of a class that has vector data members, but If my
vector object of a custom class has a vector data member my program
crashs not when I instaitant it, but if I try calling any of the member
functions, heres the code:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class CMine
{
private:
string m_yo;
vector<string> m_var;
public:
CMine(string yo = "Hello.") : m_yo(yo){m_var[0]=m_yo;}
void Show(){ cout << m_var[0] << endl; }
};
int main()
{
vector<CMine> test;
test[0].Show();
system("pause");
return 0;
}
very basic stuff, but i just dont get what i'm doing wrong or if this
is even possible.
Thanks in advace