Click here to Skip to main content
15,899,754 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: User Input Pin
Harold_Wishes7-Jul-06 10:08
Harold_Wishes7-Jul-06 10:08 
GeneralRe: User Input [modified] Pin
Zac Howland7-Jul-06 10:35
Zac Howland7-Jul-06 10:35 
GeneralRe: User Input [modified] Pin
Harold_Wishes8-Jul-06 17:36
Harold_Wishes8-Jul-06 17:36 
GeneralRe: User Input Pin
Zac Howland9-Jul-06 14:28
Zac Howland9-Jul-06 14:28 
QuestionSimple MAPI Outlook outbox problem Pin
chilituna7-Jul-06 4:45
chilituna7-Jul-06 4:45 
Questionostream operator link error Pin
mosu'7-Jul-06 4:33
mosu'7-Jul-06 4:33 
AnswerRe: ostream operator link error [modified] Pin
Viorel.7-Jul-06 4:45
Viorel.7-Jul-06 4:45 
AnswerRe: ostream operator link error Pin
Zac Howland7-Jul-06 5:11
Zac Howland7-Jul-06 5:11 
mosu` wrote:
this is test1.cpp:


The following code should be moved to a header file (you should not be including *.cpp files!):

In test1.h
#pragma once

#include <ostream>

class Address
{
private:
	int house;
	int block;

public:
	Address(int i, int j) : house(i), block(j)
	{ }

	int GetHouseNumber() const { return house; }
	int GetBlockNumber() const { return block; }

	// add accessors!  No need to make it a friend here
//	friend ostream& operator << (ostream&, const Address&);
};

inline ostream& operator<<(ostream& a, const Address& b)
{
	a << "House No " << b.GetHouseNumber() << endl;
	a << "Block Number " << b.GetBlockNumber() << endl;
	return a;
};


And in main.cpp
#include "test1.h"
int main()
{
	Address a(10,113);
	cout << a;
	return 0;
}


The error is due to the fact that test1.cpp is being compiled twice in your code and thus has multiple definitions in the object code.

If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week

Zac
QuestionRun an application inside another one Pin
xtof737-Jul-06 4:03
xtof737-Jul-06 4:03 
AnswerRe: Run an application inside another one Pin
Sarath C7-Jul-06 4:25
Sarath C7-Jul-06 4:25 
GeneralRe: Run an application inside another one Pin
Zac Howland7-Jul-06 4:30
Zac Howland7-Jul-06 4:30 
GeneralRe: Run an application inside another one Pin
Sarath C7-Jul-06 4:39
Sarath C7-Jul-06 4:39 
AnswerRe: Run an application inside another one Pin
Jun Du7-Jul-06 4:40
Jun Du7-Jul-06 4:40 
QuestionCListCtrl and Graphic Pin
ensger7-Jul-06 3:44
ensger7-Jul-06 3:44 
AnswerRe: CListCtrl and Graphic Pin
Zac Howland7-Jul-06 5:25
Zac Howland7-Jul-06 5:25 
GeneralRe: CListCtrl and Graphic Pin
ensger7-Jul-06 9:10
ensger7-Jul-06 9:10 
QuestionCreating a Bitmap from a Framegrabber Image Pin
im797-Jul-06 3:41
im797-Jul-06 3:41 
AnswerRe: Creating a Bitmap from a Framegrabber Image Pin
Justin Tay7-Jul-06 6:27
Justin Tay7-Jul-06 6:27 
AnswerRe: Creating a Bitmap from a Framegrabber Image Pin
im799-Jul-06 4:37
im799-Jul-06 4:37 
GeneralRe: Creating a Bitmap from a Framegrabber Image Pin
Justin Tay9-Jul-06 11:40
Justin Tay9-Jul-06 11:40 
GeneralRe: Creating a Bitmap from a Framegrabber Image Pin
im7910-Jul-06 21:43
im7910-Jul-06 21:43 
GeneralRe: Creating a Bitmap from a Framegrabber Image Pin
Justin Tay10-Jul-06 22:55
Justin Tay10-Jul-06 22:55 
GeneralRe: Creating a Bitmap from a Framegrabber Image Pin
im7910-Jul-06 23:12
im7910-Jul-06 23:12 
GeneralRe: Creating a Bitmap from a Framegrabber Image Pin
Justin Tay10-Jul-06 23:37
Justin Tay10-Jul-06 23:37 
GeneralRe: Creating a Bitmap from a Framegrabber Image Pin
im7911-Jul-06 1:16
im7911-Jul-06 1:16 

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.