My Computer Forum Computer Science Forum

Go Back   My Computer Forum > Computer Science Forum > Programming

Programming Programming Languages, Interpreters, and Compilers - Assembly, Declarative, Machine, Object Oriented, Iterative


Reply
 
LinkBack Thread Tools Display Modes
December 1st, 2010, 03:59 PM   #1
 
Joined: Dec 2010
Posts: 1
A little help with namespace c++

I got a little question on how to call objects in a namespace for example

Code:
namespace Company{
	class Bakery{
	private:
		int amount;
	public:
		Bakery();
      int getAmount() const;
	};
	Bakery::Bakery(){
		this->amount=100;
	}
	int Bakery::getAmount() const{
		return this->amount;
	}
};
is it even possible to do it if you have the file included in main.cpp?

Are you able to call it like this from the main file?
Code:
cout << Company::Bakery.getAmount();
Thanks in advance!
Calii is offline  
 

My Computer Forum is free to register and we welcome everyone!

Reply

  My Computer Forum > Computer Science Forum > Programming

Tags
namespace



Thread Tools
Display Modes






Copyright © 2018 My Computer Forum Forum. All rights reserved.