473,378 Members | 1,330 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

initialized a reference member of a class

How can I initialize a reference member to another member of a class? If I do this I got a compile error:

Expand|Select|Wrap|Line Numbers
  1. class A {
  2. public: A():b(0)),c(b){}
  3.  
  4. private:
  5.          int b;
  6.          int &c;
  7. }
Oct 13 '11 #1
1 2099
weaknessforcats
9,208 Expert Mod 8TB
What you have is OK after you fix your syntax errors.

a) there is an unmatched ) in the A constructor
b) the class declaration must end in a ;
Oct 14 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: supachamp | last post by:
Hi everybody, I am having great problems with the following classes. I just can't figure out why I keep getting the error message: Building file: ../edge.cc Invoking: GCC C++ Compiler g++...
8
by: ken.carlino | last post by:
Hi, Can I use Reference type as my class attribute, like this? Or I have to use pointers for class attribute? class B; class A { public: B& _b; };
8
by: Tim Clacy | last post by:
1) Is this initialising the reference 'u' to the address of the literal '2' or to the address 0x00000002? unsigned const& u = 2; 2) What is the different between the initialisation of 'u'...
6
by: faisalee | last post by:
Hi Guys, I have a question. Here goes: class clsManager { public: int x; int y; }
8
by: Bart Simpson | last post by:
If a class has a member variable that is a reference. What happens to teh class that is being referenced, when the containing class is destroyed? e.g. Class A{ }; Class B { B(const A&...
4
by: Bart Simpson | last post by:
I have a class that has a member that is a const reference: class MyClass { public: MyClass(const AnotherClass& ac); MyClass(const MyClass& mc); MyClass& operator= (const MyClass& mc); ...
2
by: Barry | last post by:
The following code compiles with VC8 but fails to compiles with Comeau online, I locate the standard here: An explicit specialization of any of the following:
2
by: Peng Yu | last post by:
Hi, I'm wondering if there is a way to initialized a member array just as the initialization of a member variable? Or I have to initialized the array inside the function body of the constructor?...
6
by: msgurikar | last post by:
Hi, How do i handle reference member variable in assignment operator and copy constructor. class A{ private: int& a; public: A(); ~A();
7
by: priethe | last post by:
I am facing the following error: cpptest-textoutput.h: In constructor âTest::TextOutput::TextOutput(Test::TextOutput::Mode, std::ostream&)â: cpptest-textoutput.h:63: error: uninitialized...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.