bug-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

(no subject)


From: manu
Subject: (no subject)
Date: Thu, 12 Jul 2001 11:13:14 +0530

Dear sir,
 
                     It's for your kind information about the bug listed below.
 
                 when we try to compile the following sample program in Linux with g++ 2.96 or by higher version , it gives the error " parser error" with Internal compilation error.
 
 
program is listed below
 

#include <iostream.h>

static int cnt = 2;

class testclass{

           public:

           int n;

           char *name;

            };

 

class Base_class {

     public:

        class child_class1

              {

               private:

                  int x,y;

               public:

                child_class1(int x_arg, int y_arg):x(x_arg),y(y_arg) { }

                int Getx(){ return x;}

                int Gety(){ return y;}

                enum Id { id = 1 };

                typedef testclass class1;

                typedef class1& ref;

                typedef const class1& const_ref;

                typedef class1* ptr;

                typedef class1* pointer;

 

            };

class child_class2

       {

        private:

            int x1,y1;

        public:

            child_class2(int x1_arg, int y1_arg):x1(x1_arg),y1(y1_arg) { }

            int Getx1(){ return x1;}

            int Gety1(){ return y1;}

            enum Id { id = 2 };

            typedef testclass class1;

            typedef const class1& ref;

            typedef const class1& const_ref;

            typedef class1* ptr;

            typedef const class1* const_ptr;

            typedef class1* pointer;

        };

public:

child_class1::class1 egclass1;

child_class2::class1 egclass2;

private:

child_class1::pointer child_class1;

child_class2::pointer child_class2;

public:

Base_class() { };

inline Base_class( child_class1::Id id, child_class1::class1& c1);

inline Base_class( child_class2::Id id, child_class2::class1& c2);

};

/*Base_class::Base_class( Base_class::child_class1::class1& c1, Base_class::child_class2::class1& c2 ){*/

Base_class::Base_class( Base_class::child_class2::Id id, Base_class::child_class2::class1& c2) : child_class11(0){

cout<<"u r in consrtuctor\n";

}

Base_class::Base_class( Base_class::child_class1::Id id, Base_class::child_class1::class1& c1) : child_class11(0){

cout<<"u r in consrtuctor\n";

}

 

 

int main()

{

int ma1,m2;

 

/* Base_class::child_class1::class1& v0(12,"ankur");

Base_class::child_class2::class1& v1(10,"manoj");

Base_class testBase,testBase1(v0,v1);

*/

Base_class testBase;

/*Base_class::child_class1 object();*/

Base_class::child_class1 object(10,20);

Base_class::child_class1::class1 testclass1;

Base_class::child_class2::class1 testclass2;

cout <<"x=="<<object.Getx()<<endl;

cout <<"y=="<<object.Gety()<<endl;

testclass1.n = 3;

testclass2.n = 5;

testclass1.name="mahendi";

testclass2.name="maanoj";

testBase.egclass1.name="my-name";

cout << "Value of cnt = " << cnt << endl;

cout <<"value 1=="<<testclass1.n<<endl;

cout <<"value 2"<<testclass2.n<<endl;

cout <<"name 1 ="<<testclass1.name<<endl;

cout <<"name 2 ="<<testclass2.name<<endl;

cout<<"name of data member declared through Base class = "<<testBase.egclass1.name<<endl;

return 0;

}

 
 
 
 
.The same program is running fine in Solaris.The problem disappears when we change the object name child_class1 & child_class2 to any other name in the following lines of.
 

child_class1::pointer child_class1;

child_class2::pointer child_class2;

note: the same names are defined for classes

                                              please send your suggessions to compile it with successfully with out changing the object names.

waiting for yor reply.

                                                                                              thabks

                                                                                                            Manoj

                                                       

 

    


reply via email to

[Prev in Thread] Current Thread [Next in Thread]