Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Vector declaration .h and initialization .cpp
Vector declaration .h and initialization .cpp [message #38154] Mon, 03 December 2012 04:01 Go to next message
nejnadusho is currently offline  nejnadusho
Messages: 60
Registered: October 2012
Member
Hi,

I cant understand how to do that.

.h File
class Menu{
		public:
			typedef Menu CLASSNAME;
			Menu();
			~Menu();
			void WidgetFactory( One<Ctrl>& x);
			void OnButton(int n);
			void ButtonGenerator(int tableCount);
			ArrayCtrl menuArray;
			void GetMenu();
						
		private:
			int buttonCounter;
			Vector<String>  menuVec;
			
			
								
	};



.cpp File
	Menu::Menu()
	{	
		
		buttonCounter = 0;
		
		menuArray.AddColumn().Ctrls(THISBACK(WidgetFactory));
		menuArray.AddColumn().Ctrls(THISBACK(WidgetFactory));
		menuArray.AddColumn().Ctrls(THISBACK(WidgetFactory));
		menuArray.AddColumn().Ctrls(THISBACK(WidgetFactory));
		
		ButtonGenerator(20/4);	
		menuArray.SetLineCy(50);
	}
	
	void Menu::ButtonGenerator(int tableCount){
		
		for (int i = 1; i <= tableCount; ++i){
			menuArray.Add();
		}
		
	}
	
	void Menu::OnButton(int n)
	{
		PromptOK(AsString(n));
	}
	
	void Menu::WidgetFactory(One<Ctrl>& x)
	{
		Button& b = x.Create<Button>();
		b.SetLabel("Table " + AsString(++buttonCounter));	
		b.SizePos();	
		b <<= THISBACK1(OnButton, buttonCounter);
	}
	
	Menu::~Menu(){
		menuArray.Clear();
	}
	
	Menu::GetMenu(){
		for(int i = 0; i < 21; ++i){{
			menuVec.???????
		}
			
		
	}



Why am I not able to access the vector here at the .cpp file?
What am I missing here?
And why would I be able to access it in the constructor in the. cpp file?


Thank you.

Best
Georgi
Re: Vector declaration .h and initialization .cpp [message #38162 is a reply to message #38154] Mon, 03 December 2012 07:23 Go to previous messageGo to next message
nejnadusho is currently offline  nejnadusho
Messages: 60
Registered: October 2012
Member
And how come I have no access in any function at the .cpp to a vector that is declared into the .h? Shocked



Best,
Georgi
Re: Vector declaration .h and initialization .cpp [message #38163 is a reply to message #38162] Mon, 03 December 2012 07:42 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi Georgi,

Dumb question: Did you #include the header file in the .cpp one? Also, are the definition and declaration in same namespace? And what exactly you mean by no access, can you post the compiler messages?

Best regards,
Honza
Re: Vector declaration .h and initialization .cpp [message #38180 is a reply to message #38154] Tue, 04 December 2012 00:03 Go to previous message
nejnadusho is currently offline  nejnadusho
Messages: 60
Registered: October 2012
Member
Honza,

Thank you for your reply.

The following was my problem.
This is the .cpp file I missed to put VOID before the Menu::GetMenu();



	Menu::GetMenu(){
		for(int i = 0; i < 21; ++i){{
			menuVec.???????
		}
			
		
	}


I apologize for the dumb mistake.
Everything works great.

Best,
Georgi
Previous Topic: GridCtrl and DropList
Next Topic: Icon size
Goto Forum:
  


Current Time: Sun Apr 28 18:30:47 CEST 2024

Total time taken to generate the page: 0.01707 seconds