- #1
Whovian
- 652
- 3
#include <iostream>
using namespace std;
class B
{
public:
int a,b;
string c;
B (int, int, string);
B ();
};
B::B (int d, int e, string f)
{
a = d;
b = e;
c = f;
}
B::B ()
{
a = 0;
b = 0;
c = "Nothing";
}
int main()
{
B Wibbly (1,2,"Wibbly");
B Wobbly ();
cout << "Wibbly: " << Wibbly.a << " " << Wibbly.b << " " << Wibbly.c << endl << "Wobbly: " << Wobbly.a << " " << Wobbly.b << " " << Wobbly.c << endl;
return 0;
}
For some reason, I get an error "error: request for member 'a' in 'Wobbly', which is of non-class type 'B ()()'" (and the same for b and c). Could anyone tell me what I'm doing wrong? I'm expecting
Wibbly: 1 2 Wibbly
Wobbly: 0 0 Nothing
EDIT: I now know that this wasn't the appropriate forum. Still, could someone please help?
using namespace std;
class B
{
public:
int a,b;
string c;
B (int, int, string);
B ();
};
B::B (int d, int e, string f)
{
a = d;
b = e;
c = f;
}
B::B ()
{
a = 0;
b = 0;
c = "Nothing";
}
int main()
{
B Wibbly (1,2,"Wibbly");
B Wobbly ();
cout << "Wibbly: " << Wibbly.a << " " << Wibbly.b << " " << Wibbly.c << endl << "Wobbly: " << Wobbly.a << " " << Wobbly.b << " " << Wobbly.c << endl;
return 0;
}
For some reason, I get an error "error: request for member 'a' in 'Wobbly', which is of non-class type 'B ()()'" (and the same for b and c). Could anyone tell me what I'm doing wrong? I'm expecting
Wibbly: 1 2 Wibbly
Wobbly: 0 0 Nothing
EDIT: I now know that this wasn't the appropriate forum. Still, could someone please help?
Last edited: