I'm just beginner in c++ and seek for help. I learn about separate compilation.Try to observe files below:
Poji1.h
#ifndef POJI1_SPEC
#define POJI1_SPEC
class Poji1 {
public:
Poji1();
void ConvToCent(double* temp);
private:
int j;
};
Poji1.cpp
#include %26lt;iostream%26gt;
#include "Poji1.h"
Poji1::Poji1()
{
j=0;
}
void Poji1::ConvToCent(double* temp)
{
int j;
for(j=0; j%26lt;6; j++)
{
*temp++ *=2.54;
}
}
lain.cpp
#include %26lt;iostream.h%26gt;
#include "Poji1.h"
void main()
{
double dblarr[6]={21.0,32.1,43.2,54.3,65.4,76.5...
int j;
Poji1 P;
for (j=0; j%26lt;6; j++)
{
cout%26lt;%26lt;endl%26lt;%26lt;"dblarr["%26lt;%26lt;j%26lt;%26lt;"]="%26lt;%26lt;dblarr...
}
P.ConvToCent(dblarr);
for(j=0; j%26lt;6; j++)
{
cout%26lt;%26lt;endl%26lt;%26lt;"dblarr["%26lt;%26lt;j%26lt;%26lt;"]="%26lt;%26lt;dblarr...
}
}
The errors are:
%26gt;ch -u ./lain.cpp
ERROR: member function '::Poji1()' not defined
at line 8 and ERROR: member function '::ConvToCent()' not defined at line 13 in file C:\Documen. Help!
Separation compilation problem ; C/C++?
need to make your functions public.
Reply:Kai says he's not going to answer that question
Reply:Just two hints. 1. C++ object members are private by default, not public. 2. When you use multiple files look up the extern key word.
I won't say any more, lest this be for a class.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment