We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,174 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Need help on calling a member function of an object of a class in c++?

So I have 3 classes, matrix.h, matrix.cc, and shortestPath.cc

shortestPath includes the .h file, which includes the matrix.cc file.

In shortestPath I've tried to call a Get method I wrote in the matrix.cc file, but I can't figure out how to call the function on the object of that class. This is the line of code I have:

char exp = mat.Get(0, 0);

I'm more concerned now with how to call the function on the object. the object of the matrix class is called mat. The parameters specify which character to return.

2
Contributors
1
Reply
58 Minutes
Discussion Span
1 Year Ago
Last Updated
2
Views
Question
Answered
MousehDragon
Newbie Poster
1 post since Dec 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

The Header (test.h)

//Donot include the cc
class test{
public:
void sayHello();
};

the test.cc

#include <test.h>
#include <iostream>
using namespace std;
void test::sayHello()
{
   cout<<"Hello\n";
}

the target class(target.cc)

#include <test.h>
class target{
public:
void callTest()
{
  test t;
  t.sayHello();
}
}
mazzica1
Junior Poster
148 posts since Oct 2011
Reputation Points: 9
Solved Threads: 27
Skill Endorsements: 0
Question Answered as of 1 Year Ago by mazzica1

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.2113 seconds using 2.72MB