S
Stanley Rice
Hello all
In the following class definition:
class iStack {
public:
iStack( int capacity )
: _stack( capacity ), _top( 0 ) {}
// ...
private:
vector< int > _stack;
int _top;
};
The date member _stack is initialized in the form _stack(capacity) in the
member initialized list. My question, how it could be? the type of _stact
is vector<int>, but the type of capacity is int.
I wander if the conversion function is called? Then I wrote the following
code:
vector<int> va = 2;
but the compiler complains.
However, If the define another class, say,
class A
{
public:
A(int a) : ia(a) {}
private:
int ia;
};
Then the code
A ca = 2;
pass.
What's the difference ?
In the following class definition:
class iStack {
public:
iStack( int capacity )
: _stack( capacity ), _top( 0 ) {}
// ...
private:
vector< int > _stack;
int _top;
};
The date member _stack is initialized in the form _stack(capacity) in the
member initialized list. My question, how it could be? the type of _stact
is vector<int>, but the type of capacity is int.
I wander if the conversion function is called? Then I wrote the following
code:
vector<int> va = 2;
but the compiler complains.
However, If the define another class, say,
class A
{
public:
A(int a) : ia(a) {}
private:
int ia;
};
Then the code
A ca = 2;
pass.
What's the difference ?