473,385 Members | 1,555 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Error C2511: Overloaded member function not found

Hi guys. Haven't done C++ in a while and I've never been great with classes but I'm trying to make a compiler using Lex/Yacc. I've sorted most of the errors, all apart two which are both overloaded member functions that haven't been found in the class.

Here's the class definition inside DetFinAut.h:

Expand|Select|Wrap|Line Numbers
  1. #ifndef DETFINAUT_H
  2. #define DETFINAUT_H
  3. #include <iostream>
  4. #include <string>
  5.  
  6. class DetFinAut
  7. {
  8. public:
  9.     DetFinAut();
  10.     DetFinAut(char,int,int,int,int,std::string);
  11.     static void restart();
  12.     static char run(std::string);
  13.  
  14. private:
  15.     char languageABC[36];
  16.     int numStates;
  17.     static int startState;
  18.     static std::string outputs[6];
  19.     int transTable[6][36];
  20.  
  21. public:
  22.     static void step(char);
  23. };
  24.  
  25. #endif
  26.  
And here is the .cpp that hosts the actual functions. I've stripped them both of most of the unnecessaries but I can give the rest of the code if needed.

Expand|Select|Wrap|Line Numbers
  1. #include "detfinaut.h"
  2. #include <iostream>
  3. #include <string>
  4. using namespace std;
  5.  
  6. DetFinAut::DetFinAut(char inputABCIn[36], int numStatesIn, int startState, int acceptStatesIn, int tableIn[6][36], string outputsDef[])
  7. {
  8.     languageABC = inputABCIn;
  9.     numStates = startState;
  10.     startState = numStatesIn;
  11.     transTable = tableIn;
  12.     outputs = *outputsDef;
  13.  
  14.     DetFinAut::restart();
  15. }
  16.  
  17. void DetFinAut::restart()
  18. {
  19.     actState = startState;
  20.     stopped = false;
  21. }
  22.  
  23. void DetFinAut::step(string inputs)
  24. {
  25.     if(!DetFinAut::isStopped())
  26.     {
  27.         if (nextState(actState,inputs) == -1) stopped = true;
  28.         else actState = destination;                    
  29.     }
  30. }
  31.  
  32. char DetFinAut::run(string inputs)
  33. {
  34.         for(int i=0; i<inputs.length(); i++)
  35.         {
  36.             step(inputs[i]);
  37.             if (isStopped()) break;
  38.         }
  39.         if (isAccepting()) return getOutput(getState()); 
  40.         else return NULL;
  41. }
  42.  
Thanks in advance guys! Spent several hours over this and it'd be great to finally get it sorted so I can move on!

Barnz
Jan 21 '08 #1
2 16837
gpraghuram
1,275 Expert 1GB
Hi guys. Haven't done C++ in a while and I've never been great with classes but I'm trying to make a compiler using Lex/Yacc. I've sorted most of the errors, all apart two which are both overloaded member functions that haven't been found in the class.

Here's the class definition inside DetFinAut.h:

Expand|Select|Wrap|Line Numbers
  1. #ifndef DETFINAUT_H
  2. #define DETFINAUT_H
  3. #include <iostream>
  4. #include <string>
  5.  
  6. class DetFinAut
  7. {
  8. public:
  9.     DetFinAut();
  10.     DetFinAut(char,int,int,int,int,std::string);
  11.     static void restart();
  12.     static char run(std::string);
  13.  
  14. private:
  15.     char languageABC[36];
  16.     int numStates;
  17.     static int startState;
  18.     static std::string outputs[6];
  19.     int transTable[6][36];
  20.  
  21. public:
  22.     static void step(char);
  23. };
  24.  
  25. #endif
  26.  
And here is the .cpp that hosts the actual functions. I've stripped them both of most of the unnecessaries but I can give the rest of the code if needed.

Expand|Select|Wrap|Line Numbers
  1. #include "detfinaut.h"
  2. #include <iostream>
  3. #include <string>
  4. using namespace std;
  5.  
  6. DetFinAut::DetFinAut(char inputABCIn[36], int numStatesIn, int startState, int acceptStatesIn, int tableIn[6][36], string outputsDef[])
  7. {
  8.     languageABC = inputABCIn;
  9.     numStates = startState;
  10.     startState = numStatesIn;
  11.     transTable = tableIn;
  12.     outputs = *outputsDef;
  13.  
  14.     DetFinAut::restart();
  15. }
  16.  
  17. void DetFinAut::restart()
  18. {
  19.     actState = startState;
  20.     stopped = false;
  21. }
  22.  
  23. void DetFinAut::step(string inputs)
  24. {
  25.     if(!DetFinAut::isStopped())
  26.     {
  27.         if (nextState(actState,inputs) == -1) stopped = true;
  28.         else actState = destination;                    
  29.     }
  30. }
  31.  
  32. char DetFinAut::run(string inputs)
  33. {
  34.         for(int i=0; i<inputs.length(); i++)
  35.         {
  36.             step(inputs[i]);
  37.             if (isStopped()) break;
  38.         }
  39.         if (isAccepting()) return getOutput(getState()); 
  40.         else return NULL;
  41. }
  42.  
Thanks in advance guys! Spent several hours over this and it'd be great to finally get it sorted so I can move on!

Barnz
You have declared the method for default constructor , but where is the body of that?
Also i am not very clear with ur question.
You are telling you cant find the overloaded funtion, means?


Raghuram
Jan 22 '08 #2
weaknessforcats
9,208 Expert Mod 8TB
DetFinAut::DetFinAut(char inputABCIn[36], int numStatesIn, int startState, int acceptStatesIn, int tableIn[6][36], string outputsDef[])
{
etc...
This has a final argument of a string array, which is a string*.

The class declares the final argument as a string.

Not good.
Jan 22 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Krish | last post by:
Hi There, I am having problem when I compile a code which I create to test a source file. The errors are : error C2144: syntax error : 'void' should be preceded by ';' error C2511: 'void...
3
by: sandSpiderX | last post by:
Hi, I am trying the following struct X { static void f(){} }; void (X::*pf)();
7
by: jon wayne | last post by:
Hi I'm a little confused here about the lifetime of a static pointer to member function, Say, I declare,define & initialize a static ptr to mem function in the header file of a class(the class...
4
by: Aaron Walker | last post by:
Greetings, I'm attempting to write my first *real* template function that also deals with a map of strings to member function pointers that is making the syntax a little tricky to get right. ...
1
by: joseph cook | last post by:
I'm confused by this output. I would expect the more specific overloaded function to be selected: #include <iostream> class Base { }; class Derived : public Base {};
2
by: mrstephengross | last post by:
Hi folks! I'm trying to create a function pointer to a templatized, static, overloaded member function. My class (Mgr) has two functions with the same name: "go". The first takes a T reference (T...
2
by: Elliott | last post by:
Hello Everyone, I have a function in a header (KeyDialog.h) as such: void setKey(Key&); The function implementation is as such (KeyDialog.cpp): void KeyDialog::setKey(Key& k1) {
1
by: mersinli | last post by:
Hi, I have got seven error and I dont find why compiler find error.. //commission class definition #ifndef COMMISSION_H #define COMMISSION_H #include <string> using std::string;
1
by: sunil | last post by:
Hello, I have a template class as follows which has a static function called foo, as you see below the class declaration, there are specializations for foo for different specializations of T, the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.