Jump to content
  • Advertisement
Sign in to follow this  
Tradone

Subclass cannot recognize root methods

This topic is 4466 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

Data.cpp:25: error: no matching function for call to `Data::Set(const char[6], const char[2])' Data.cpp:9: note: candidates are: void Data::Set(std::string) Data.cpp:27: error: no matching function for call to `Data::Set(const char[10], const char[2])' Data.cpp:9: note: candidates are: void Data::Set(std::string) *** Error code 1
//Config.h
#if !defined(CONFIG)
#define CONFIG

#include <string>
#include <iostream>
#include <map>
#include <boost/algorithm/string.hpp>

#include "Singleton.h"
#include "Algorithms.h"

class Config{
	public:
		Config();
		void Set(std::string path);
		void Set(std::string key, std::string value);
		void Save();

		std::map <std::string, std::string> Get();
		std::map <std::string, std::string>* pGet();
		std::string Get(std::string& key);
		std::string Get(const std::string& key);
	//end public:

	protected:
		std::string filePath;
		std::map <std::string, std::string> config;
	//end private:
};
#endif




//Data.h
#if !defined(DATA)
#define DATA

#include <fstream>
#include <string>
#include <iostream>
#include <map>

#include "Singleton.h"
#include "Algorithms.h"
#include "Config.h"

#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/map.hpp>
//#include "CaseInsensitiveMapOrder.h"

#pragma comment(lib, "libboost_serialization-vc71-sgd.lib")

class Data : public Config{
	public:
		Data();
		void Set(std::string filePath);
		void Save();
	//end public:
};
#endif


Data.cpp line 25 & line 27 respectively
		Set("count","0");
		Set("downcount","0");
As you can see and as the title suggests. the subclass cannot recognize methods in its parent class. I don't have much experience with inheritence, can you guide me father?

Share this post


Link to post
Share on other sites
Advertisement
I think that's called shadowing or something. You have a function with the same name so it hides the originals. Try being specific, like calling Config::Set("count","0");, I think that'll work.

Share this post


Link to post
Share on other sites
try this and tell me if it works:

std::string s1 = "downcount";
std::string s2 = "0";
Set(s1,s2);

methinks it's not an inheritance issue.

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!