B
Bruce
OK, this won't compile saying it can't access private members declared in
class F. I don't get it and even if I make the entire class public, it
still says that. I realize it has something to do with the constructors
but not what.
Second, I'd like to take the line:
// Create an vector of 1000 F objects init'd to 1,1
vector<F> F(1000,F(1,1));
And add that as private data to Class B but it fails saying "syntax error
constant"
I'm really trying to avoid using an array of classes but they're making it
difficult on me.
# include <vector>
# include <string>
using namespace std;
class F
{
F() { X = 0; Y = 0; P = 0;};
F( unsigned long x, unsigned long y) {X = x; Y = y; P = x * y;};
~F();
private:
unsigned long X;
unsigned long Y;
unsigned long P;
};
class B
{
B() {strValue = "1";};
B( string &val){ strValue = val;};
private:
string strValue;
};
int main()
{
// Create an vector of 1000 F objects init'd to 1,1
vector<F> F(1000,F(1,1));
// do something else
return 0;
}
class F. I don't get it and even if I make the entire class public, it
still says that. I realize it has something to do with the constructors
but not what.
Second, I'd like to take the line:
// Create an vector of 1000 F objects init'd to 1,1
vector<F> F(1000,F(1,1));
And add that as private data to Class B but it fails saying "syntax error
constant"
I'm really trying to avoid using an array of classes but they're making it
difficult on me.
# include <vector>
# include <string>
using namespace std;
class F
{
F() { X = 0; Y = 0; P = 0;};
F( unsigned long x, unsigned long y) {X = x; Y = y; P = x * y;};
~F();
private:
unsigned long X;
unsigned long Y;
unsigned long P;
};
class B
{
B() {strValue = "1";};
B( string &val){ strValue = val;};
private:
string strValue;
};
int main()
{
// Create an vector of 1000 F objects init'd to 1,1
vector<F> F(1000,F(1,1));
// do something else
return 0;
}