Skip to main content
gamedev.net
🔒 Locked

Subclass cannot recognize root methods

Started by Tradone Apr 29, 2006 at 9:36 PM 3 replies 500+ views
Original Post
Tradone
Tradone
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?
smart_idiot
smart_idiot
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.
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other
leiavoia
leiavoia
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.
Tradone
Tradone
I tried both suggestions, and smart_idiot wins :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.