Jump to content
  • Advertisement
Sign in to follow this  
Tradone

Classes Error in Declaring Method.

This topic is 4526 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I thought I did everything corrently...
//print.h
#if !defined(PRINT)
#define PRINT
#include <string>
#include <map>
#include <iostream>
#include "Cookie.h"
#include "Parameter.h"
#include "Path.h"
#include "Config.h"
#include "Algorithms.h"

//header
class Print {
	public:
		Print();
		void Error( std::string, std::string );
		void ErrorMessage( std::string );

		void Header( std::string );
		void Header( std::string, std::string );
		void Body();
		void Body( std::string );
		void Tail();
		void Tail( std::string );

		void Cookie( );
		void Parameter( );
		void Path( );
		void Config( );

		void SetCookie( Cookie& para_cookie );
		void SetParameter( Parameter& para_parameter );
		void SetPath( Path& para_path );
		void SetConfig( Config& para_config );

	//end public:
	private:
		void SoftwareInfo( std::string shenuVersion );
		void CSS( std::map< std::string, std::string > para_fieldData );
		const std::string shenuVersion;

		const static std::string CSSClasses[2][3];
		const static std::string CSSInstances[2][6];

		std::map<std::string, std::string>::const_iterator loop;
		Cookie cookie;
		Parameter parameter;
		Path path;
		Config config;
	//end private:

};

#endif




Print.h:31: error: variable or field `SetCookie' declared void Print.h:31: error: expected `;' before '(' token Print.h:32: error: variable or field `SetParameter' declared void Print.h:32: error: expected `;' before '(' token Print.h:33: error: variable or field `SetPath' declared void Print.h:33: error: expected `;' before '(' token Print.h:34: error: variable or field `SetConfig' declared void Print.h:34: error: expected `;' before '(' token Print.h:46: error: `Cookie' does not name a type Print.h:47: error: `Parameter' does not name a type Print.h:48: error: `Path' does not name a type Print.h:49: error: `Config' does not name a type ... ... ... new_shenu.cpp: In function `int main()': new_shenu.cpp:23: error: 'class Print' has no member named 'SetCookie' new_shenu.cpp:24: error: 'class Print' has no member named 'SetParameter' new_shenu.cpp:25: error: 'class Print' has no member named 'SetPath' new_shenu.cpp:26: error: 'class Print' has no member named 'SetConfig' new_shenu.cpp:46: error: invalid use of void expression YES I DO!! what's going on? I think it can't load the Cookie.h or other header files.... because it even gives Cookie does nto name a type error. please help, I can provide additional information.

Share this post


Link to post
Share on other sites
Advertisement
I think your code is getting messed up by the fact that you have the functions "Cookie()", "Parameter()", "Path()", and "Config()" which are named exactly the same as your Cookie, Parameter, Path, and Config classes. Maybe change those functions to be "getCookie()", "getParameter()" and so on... ?

Share this post


Link to post
Share on other sites
I was reading my C++ book the other day by Bjarne Stroustrup and I think I remember in the back under compatibility that you could have classes/structs with the same name as functions... All you need to do is prefix the word class/struct for your variables.


class Foo
{

};

class Bar
{
public:
Foo();

private:
class Foo foo; // Maybe this needs to be seen before the function ???
};

Share this post


Link to post
Share on other sites
Print.h:46: error: `Cookie' does not name a type
Print.h:47: error: `Parameter' does not name a type
Print.h:48: error: `Path' does not name a type
Print.h:49: error: `Config' does not name a type


Theres what someone was saying about changing the names. You can name them the same.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!