Klassen ineinander verschachtelt
-
Wie spreche ich den Konstruktor von einer Klasse an, die sich schon in einer Klasse beinfdet? So wie ichs mache, is es anscheinend falsch:
#include <iostream> using namespace std; class Ober { class Unter { public: Unter(int a_,int b_,int c_); int a; int b; int c; }; }; Ober::Unter::Ober::Unter(int a_,int b_,int c_) :a(a_),b(b_),c(c_) { } int main() { return 0; }**
Compiling: C:\MinGW\Andi\test.cpp
C:\MinGW\Andi\test.cpp:17: error:class Ober::Unter::Ober' has not been declared C:\\MinGW\\Andi\\test.cpp:18: error: ISO C++ forbids declaration ofUnter' with no type
C:\MinGW\Andi\test.cpp: In function `int Unter(int, int, int)':
C:\MinGW\Andi\test.cpp:18: error: only constructors take base initializers
Process terminated with status 1 (0 minutes, 0 seconds)
3 errors, 0 warnings
**MfG
StrombergEDIT:
Habs selber gelöst, muss "Ober::Unter::Unter(....)" heißen! Peinlicher Fehler
-
Ober::Unter::Unter(int a_,int b_,int c_) :a(a_),b(b_),c(c_) { }Gruss Simon
Edit: ok, bin mal wieder viel zu spät.