[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
nested classes
From: |
cronus |
Subject: |
nested classes |
Date: |
Mon, 23 Aug 2004 20:11:35 +0200 |
User-agent: |
KMail/1.6.2 |
Hi
How to I specify casts with nested classes, e.g.
if I enter the debugger command
print (A::AA *)a
I get the error message:
A parse error in expression, near ')a'
I am using ddd version 3.3.9, and gdb version 6.1-debian.
Thanks in advance
#include <iostream>
class Base {
public:
int getB(void) { return _b;}
void setB(int b) { _b = b; }
private:
int _b;
};
class A {
public:
class AA : public Base {
public:
AA(int aa):_aa(aa){}
int getAA(void) {
return getB()*_aa;
}
private:
int _aa;
};
};
class C : public Base {
public:
C(int c):_c(c){}
int getC(void) {
return getB()*_c;
}
private:
int _c;
};
int main (void) {
Base *a = new A::AA(5);
a->setB(4);
// stop here and enter the command: print (A::AA *) a
Base *c = new C(5);
c->setB(4);
std::cout << "1: " << a->getB() << std::endl;
std::cout << "2: " << ((A::AA *)a)->getAA() << std::endl;
std::cout << "3: " << ((C *)c)->getC() << std::endl;
return 0;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- nested classes,
cronus <=