Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have built a windows form application in C++ and I created a class with methods. But when accessing those methods it doesn't work.I have included header files as well as those methods are public. Please help me with this problem.

Here is the method.

C++
int Segmentation::Vertical_Projection(char *filename,int width,int height){...}

This is inside Segmentation.cpp and my class name is Segmentation.

C++
class Segmentation
{
public:
    Segmentation(void);
    ~Segmentation(void);

    IplImage* Resize(IplImage *img);
    char Horizontal_projection(int width,int height,IplImage *binary,int countPositions,int *pos);
    int Vertical_Projection(char *filename,int width,int height);
};

This is inside Segmentation.h

I was trying to access that method in another source file with including the header file.
Posted

1 solution

This method is an instance method, not a static method. You cannot call it like this. You should first make an instance of Segmentation^ myInstance using gcnew and then call it with this instance via myInstance->Vertical_Projection(/* ... */):
C++
Segmentation^ myInstance = gcnew Segmentation();
myInstance->Vertical_Projection(/* ... */);


Please see: http://msdn.microsoft.com/en-us/library/te3ecsc8%28v=vs.110%29.aspx[^].

Let me tell you that, unfortunately, no answers can help you to do any programming at all: at this moment, you have no clue. This is such a basic thing, that you really should start from the very beginning. Grab a book or a manual and start from the very beginning, doing the simplest possible exercises as you go. When you get some confidence, come back and ask your questions.

—SA
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900