468,513 Members | 1,751 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,513 developers. It's quick & easy.

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 15931
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,207 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

Post your reply

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

Similar topics

3 posts views Thread by Krish | last post: by
3 posts views Thread by sandSpiderX | last post: by
7 posts views Thread by jon wayne | last post: by
1 post views Thread by joseph cook | last post: by
2 posts views Thread by mrstephengross | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.