Click here to Skip to main content
15,897,371 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questioncan anybody help me out Pin
philiptabraham31-Jan-08 22:20
philiptabraham31-Jan-08 22:20 
AnswerRe: can anybody help me out [modified] Pin
Iain Clarke, Warrior Programmer31-Jan-08 22:37
Iain Clarke, Warrior Programmer31-Jan-08 22:37 
JokeIgnore this - I don't need any assistance Pin
Cedric Moonen31-Jan-08 22:51
Cedric Moonen31-Jan-08 22:51 
GeneralRe: Ignore this - I don't need any assistance Pin
CPallini31-Jan-08 23:15
mveCPallini31-Jan-08 23:15 
GeneralRe: Ignore this - I don't need any assistance Pin
Iain Clarke, Warrior Programmer31-Jan-08 23:42
Iain Clarke, Warrior Programmer31-Jan-08 23:42 
GeneralRe: Ignore this - I don't need any assistance Pin
CPallini31-Jan-08 23:52
mveCPallini31-Jan-08 23:52 
GeneralRe: Ignore this - I don't need any assistance Pin
Cedric Moonen1-Feb-08 0:07
Cedric Moonen1-Feb-08 0:07 
GeneralRe: can anybody help me out Pin
CPallini31-Jan-08 23:01
mveCPallini31-Jan-08 23:01 
Iain Clarke wrote:
2/ Less trivially, the first example just calls the constructor. The second example makes two objects, (obj, and a temp one), then copies temp to obj, then destroys the temp object.


I thought the same. But I made a little test (optimization disabled):
#include <iostream>
using namespace std;

class MyClass
{
public:
	int _a, _b;
	MyClass(){}
	MyClass(int a, int b):_a(a), _b(b){}
	// copy constructor and assignment operator arbitrarly messed up.
	MyClass(const MyClass & proto)
	{
		_a = 0;
		_b = 0;
	} 
	MyClass & operator = (const MyClass & proto)
	{
		_a = proto._b;
		_b = proto._a;
		return *this;
	}
};


void main()
{
	MyClass my1(3,2);
	MyClass my2=MyClass(3,2);

	MyClass my3(my1);
	MyClass my4;
	my4=my1;

	cout << "my1: " << my1._a << " " << my1._b << endl;
	cout << "my2: " << my2._a << " " << my2._b << endl;
	cout << "my3: " << my3._a << " " << my3._b << endl;
	cout << "my4: " << my4._a << " " << my4._b << endl;

}
</iostream>


and to my surprise, the output:
my1: 3 2
my2: 3 2
my3: 0 0
my4: 2 3


Well I'm really upset about. What do you think?

If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.

[my articles]


GeneralRe: can anybody help me out Pin
Cedric Moonen31-Jan-08 23:08
Cedric Moonen31-Jan-08 23:08 
GeneralRe: can anybody help me out Pin
CPallini31-Jan-08 23:21
mveCPallini31-Jan-08 23:21 
GeneralRe: can anybody help me out Pin
Iain Clarke, Warrior Programmer31-Jan-08 23:13
Iain Clarke, Warrior Programmer31-Jan-08 23:13 
GeneralRe: can anybody help me out Pin
CPallini31-Jan-08 23:45
mveCPallini31-Jan-08 23:45 
QuestionIs there a Windows API or a method which can convert FILE* to HANDLE of a file or convert HANDLE to FILE* ?? Pin
Jude Deng31-Jan-08 22:13
Jude Deng31-Jan-08 22:13 
GeneralRe: Is there a Windows API or a method which can convert FILE* to HANDLE of a file or convert HANDLE to FILE* ?? Pin
Iain Clarke, Warrior Programmer31-Jan-08 22:53
Iain Clarke, Warrior Programmer31-Jan-08 22:53 
GeneralRe: Is there a Windows API or a method which can convert FILE* to HANDLE of a file or convert HANDLE to FILE* ?? Pin
Jude Deng1-Feb-08 19:01
Jude Deng1-Feb-08 19:01 
GeneralRe: Is there a Windows API or a method which can convert FILE* to HANDLE of a file or convert HANDLE to FILE* ?? Pin
Jude Deng1-Feb-08 22:03
Jude Deng1-Feb-08 22:03 
GeneralRe: Is there a Windows API or a method which can convert FILE* to HANDLE of a file or convert HANDLE to FILE* ?? Pin
Iain Clarke, Warrior Programmer2-Feb-08 12:32
Iain Clarke, Warrior Programmer2-Feb-08 12:32 
GeneralRe: Is there a Windows API or a method which can convert FILE* to HANDLE of a file or convert HANDLE to FILE* ?? Pin
Jude Deng2-Feb-08 13:04
Jude Deng2-Feb-08 13:04 
Generaledit box issue Pin
Chandrasekharan P31-Jan-08 19:53
Chandrasekharan P31-Jan-08 19:53 
GeneralRe: edit box issue Pin
Hamid_RT31-Jan-08 19:54
Hamid_RT31-Jan-08 19:54 
GeneralRe: edit box issue Pin
Chandrasekharan P31-Jan-08 20:35
Chandrasekharan P31-Jan-08 20:35 
GeneralRe: edit box issue Pin
Hamid_RT31-Jan-08 21:19
Hamid_RT31-Jan-08 21:19 
GeneralRe: edit box issue Pin
Chandrasekharan P31-Jan-08 22:43
Chandrasekharan P31-Jan-08 22:43 
GeneralRe: edit box issue Pin
Hamid_RT31-Jan-08 23:08
Hamid_RT31-Jan-08 23:08 
GeneralRe: edit box issue Pin
Cedric Moonen31-Jan-08 23:14
Cedric Moonen31-Jan-08 23:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.