| |

VerySource

 Forgot password?
 Register
Search
View: 785|Reply: 6

Solve problems that class members cannot find

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-22 19:20:01
| Show all posts |Read mode
I added a function declaration getE (char * c, int x) to the tga_writer class of the tga file and defined it in the tga.cpp file.

A new MFC project is created. When a button is pressed, the getE function is called, but the error C2039: "GetE" is not always a member of "tga_writer". When calling other original functions in tga_writer, the system will not prompt an error, why?
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-2 11:36:01
| Show all posts
Have you set getE to inline, sometimes call the inline function outside the class, this will be the case
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-2-2 13:09:01
| Show all posts
Not set to inline
Reply

Use magic Report

0

Threads

70

Posts

42.00

Credits

Newbie

Rank: 1

Credits
42.00

 United States

Post time: 2020-2-3 17:30:02
| Show all posts
What about the code?
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-2-4 14:00:01
| Show all posts
class tga_writer
{
  FILE * Pfile;
  int width, height;

public:
  int GetE (char * filePath, int X, int Y, int compRatio);
}

defined in tag.cpp

A.cpp:
 tga_writer tw = new tga_writer ();
 tw-> GetE (...........);

2003 error: error C2039: "GetE": not a member of "tga_writer"
Reply

Use magic Report

0

Threads

9

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-2-5 10:30:01
| Show all posts
class tga_writer
{
FILE * Pfile;
int width, height;

public:
int GetE (char * filePath, int X, int Y, int compRatio);
};
void tga_writer :: int GetE (char * filePath, int X, int Y, int compRatio) ();

void main () {
tga_writer * tw = new tga_writer;
tw-> GetE ();
delete tw;
}
Reply

Use magic Report

0

Threads

70

Posts

42.00

Credits

Newbie

Rank: 1

Credits
42.00

 China

Post time: 2020-2-5 14:15:02
| Show all posts
You did not achieve

int GetE (char * filePath, int X, int Y, int compRatio);
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list