#include <stdio.h>
#include <conio.h>
namespace A
{
namespace B
{
struct AB
{
AB (int i, int j)
{
a=i;
b=j;
}
int a;
int b;
void add()
{
printf ("\n value: %d",a+b);
printf ("\n"); //Why not just change the above line to printf ("\n value: %d\n",a+b); ?
}
};
}
}
int main ()
{
A::B::AB Text (3, 5);
Text.add (); //I got 8 here...
getch ();
return 0;
}
I doubt that it will matter with this, but what compiler are you using?