problem feeling in namespaces concept

October 8, 2010 at 01:44:12
Specs: Windows XP
i am trying to sue concept of namespace but i am not getting right output..now i am confused on it
plz help me
foo.h
namespace foo
{

int Dosomething(int nX,int nY) // not a class, its gloabal function
{
return nX+nY;
}
}

Go.h

namespace Go ///go namesapce that have function same as defiend in other namespace file ,not a vlass
{
int Dosomething(int nX, int nY) //glaobal functions , not class
{
return nX-nY;
}
}

Main.cpp

#include "stdafx.h"
#include "foo.h"
#include "Go.h"
#include <iostream>


int _tmain(int argc, _TCHAR* argv[])
{

using namespace std;
cout<<Go::Dosomething(4,3);
cout<<foo::Dosomething(4,3);
return 0;
}


I am confused, i got output only 17,why

it should be 1 and and 7..
why its 17 output...

i will be thanks full to all of you..
thanks in advance!


See More: problem feeling in namespaces concept

Report •


#1
October 9, 2010 at 16:15:10
why its 17 output...
It's actually 1 and 7, but you didn't add any line breaks or whitespace, so it runs together.

How To Ask Questions The Smart Way


Report •

#2
October 12, 2010 at 04:09:27
ohhh thanks Mr. Razor..

Report •

Related Solutions


Ask Question