|
|
|
|
Ik ben aan het expirimenteren met het werken met losse modules. Nu heb ik een project in MSVC6++ bestaande uit 3 bestanden nl
abc.h Code:
class vkv
{
public:
void coeff(double aa, double bb, double cc);
bool losOp();
double wortel1() const
{
return x1;
}
double wortel2() const
{
return x2;
}
private:
double a, b, c, x1, x2;
};
Code:
#include <cmath>
#include "abc.h"
void vkv::coeff(double aa, double bb, double cc)
{
a = aa;
b = bb;
c = cc;
}
bool vkv::losOp()
{
double D = b * b - 4 * a * c;
if (a == 0 || D < 0)
{
return false;
}
double wD = sqrt(D);
x1 = (-b + wD)/(2 * a);
x1 = (-b - wD)/(2 * a);
return true;
}
Code:
#include <iostream>
#include "abcimpl.cpp"
using namespace std;
int main()
{
double a, b, c;
cout << "Typ a, b, en c in: ";
cin >> a >> b >> c;
vkv v;
v.coeff(a, b, c);
if (v.losOp())
{
cout << "Wortels: " << v.wortel1()
<< " " << v.wortel2() << endl;
}
else
cout << "Geen reele wortels.\n";
return 0;
}
Code:
Compiling... abcimpl.cpp Linking... abcapp.obj : error LNK2005: "public: void __thiscall vkv::coeff(double,double,double)" (?coeff@vkv@@QAEXNNN@Z) already defined in abcimpl.obj abcapp.obj : error LNK2005: "public: bool __thiscall vkv::losOp(void)" (?losOp@vkv@@QAE_NXZ) already defined in abcimpl.obj Debug/abcformule.exe : fatal error LNK1169: one or more multiply defined symbols found Iemand een idee |
|
| Advertentie | |
|
|
|
![]() |
|
|