Hello, I have created class, that contains several strings. It's minor version is:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
#include <iostream>
#include <string>
using namespace std;
class Opis{
private:
string people;
string structures;
string ways;
public:
//Constructors
Opis() {}
Opis(string pe){people = pe;}//Short version of long constructor
Opis(string pe, string st, string way)
{assign(pe, st, way);}
Opis operator=(string pe){people = pe;}
void assign(string pe,string st,string way);
string show_pe() const {return people;}
string show_st() const {return structures;}
string show_way() const {return ways;}
void Opis::assign(string pe,string st, string way,) {
people = pe;
structures = st;
ways = way;
}
|
So mainly that's the class, it has also friend ostream << operator, but since it works well and it requires a bit of space, i won't insert it.
My problem is, that I want to implement this in other program. Next program is imho way too long to instert it here. Anyway, here's my problem:
Second program includes "Opis.cpp"(previous code). Code fits well, no problem with that, but my second program has two int variables: X and Y, and they change depending on user's input. I want my program to call Opis depending on X and Y. I wanted to create array of Opis(something like Opis name[30][30], and then assign to name[0][0] something like this:
name[0][0]("People funny");
But it doesn't work. Compiler shows thiss message:
no match for call to '(Opis)(const char[13])'
I wanted to assign many various strings to name, so I could use something like cout<<name[x][y] and it would show the result as I want, but I can't create array of my class correctly. Any help?:)
Thanks in advance!