Sign in to follow this  

Subclass cannot recognize root methods

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

This topic is 4249 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this