[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

C++: Kalde sin egen konstruktor



Hejsa,

Hvis man i en konstruktor ønsker at kalde en anden konstruktor i samme
klasse for at genbruge koden derfra, hvordan gør man det? 

Jeg har prøvet følgende:

class A {
public:
  A( int i ) {
    this->i = i;
  } // constr.
  
  A( double d ) { // : A( 2 ) { // <- DETTE VIRKER IKKE
    i = 2;
    this->d = d;
  } // constr.
private:
  int i;
  double d;
}; // A

Men hvis jeg placerer kaldet i initializer listen brokker kompileren
sig bare over at A ikke er en basis klasse for A selv.

Mvh,
 Martin


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:08 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *