473,387 Members | 1,925 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,387 software developers and data experts.

Declaration and initialization of the same object name

Hi all,

I'm reviewing some C++ notes and came across this line of code in a section demonstrating copy/assignment constructor use:

Expand|Select|Wrap|Line Numbers
  1. struct D {
  2.   int i;
  3.   B b1, b2;
  4. };
  5.  
  6. int main() {
  7.   D d = d;    // bitwise/memberwise copy
  8.   d = d;    // bitwise/memberwise assignment
  9. }
  10.  
The second line in main() makes sense to me because the instance with name 'd' has already been defined.

However, in the first line of main(), what is happening exactly? ? How can an instance of D with name 'd' be initialized with an instance of D also with name 'd'? Chicken or the egg?

Thanks in advance
Dec 11 '10 #1
0 1766

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

Similar topics

2
by: Jim Jewett | last post by:
I have often wanted to pass arguments to a module. Tyically, these are globals, such as DEBUG or VERBOSE that are set at the top of the module -- and I want to use a different value. For modules...
2
by: rockie12 | last post by:
I have a db that has a table x in it called data1 I have a program that does to things, updates values in the data1 table and also inserts new rows into this table. The update existing values...
1
by: Doug | last post by:
I am sending out snapshot reports and I would like to change the name given to that particular snapshot report to include a date range instead of just the report name. Is there a way to add...
0
by: Wayne Aprato | last post by:
Can anyone please help me with the following madness in Access 2003 (2000 file format). I am using 2 similar funtions, the first which works fine to save reports as snapshots: On Error Resume...
3
by: Mr.KisS | last post by:
Hello all, I'm working with : WinXP PRO SP1, MS SQL 2005 Express, Visual Web Dev 2005 Express. I have an aspx page which must execute a stored procedure : ______________ try {...
2
by: Jerry Nelson | last post by:
I get the following error: WGA_Update is a view not a Table Invalid object name 'WGA_Update'. Description: An unhandled exception occurred during the execution of the current web request....
5
by: Phil Ward | last post by:
The following has recently arose and it is the first time I have noticed this behaviour. I have been using a self-defined string class. It's form is class CMyString { public: ... (no public...
2
by: veryrandomname | last post by:
I'm a beginner in C++ and i'm confused about object name. let's pretend that there's code like this: class blaclass{ public: void dosomething(){cout << "doing something"}; }
7
by: pmcarl | last post by:
I am very new to object oriented programming, I used to program in a variety of languages. I stopped about 15 years ago as my needs diminished. I last programmed in clipper5. I am trying to...
4
by: Curious | last post by:
I got an exception when executing the SQL statement in my code below. The error is "Invalid object name 'db_dynamic_trading.dbo.TrdRpt_broker_list'". I know for a fact that...
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.