I have a class contains_int that contains only an integer value.
I have a class contains_contains_int that contains only an object of class
contains_int.
Here is the code:
#include<iostream>
class contains_int {
int i;
public:
contains_int(int ii): i(ii) {}
void printme() {cout << "( int: " << i << " )"; }
int getme() {return i;}
};
class contains_contains_int {
contains_int c_i;
public:
contains_contains_int(contains_int c_ii): c_i(c_ii) {}
void printme() {cout << "( c_i : ";
c_i.printme(); cout << " )"; }
};
class contains_contains_contains_int {
contains_contains_int cc_i;
public:
contains_contains_contains_int(contains_contains_int cc_ii) :
cc_i(cc_ii) {}
void printme() {cout << "( cc_i : ";
cc_i.printme(); cout << " )"; }
};
int main() {
int a=7;
contains_int b(a);
contains_contains_int c(b);
contains_contains_contains_int d(c);
cout << " a = ( " << a << " )" << endl;
cout << " b = "; b.printme(); cout << endl;
cout << " c = "; c.printme(); cout << endl;
cout << " d = "; d.printme(); cout << endl;
contains_contains_contains_int x( contains_contains_int (
contains_int(10) ));
cout << " x = "; x.printme(); cout << endl; //line A
}
Here is the DJGPP error message:
In function `int main()':
Error (line A): request for member `printme' in `x', which is of
non-aggregate type `contains_contains_contains_int ()()'
My issue is that I would like to create objects like x,
rather than having to build them up line-by-line as I do with the series a,
b, c and d.
I posted this problem on the newsgroup alt.comp.lang.learn.c-c++. A couple of people managed to successfully compile it: one on VC++6.0 and one one MSVC++.
Thanks.