Problème avec class en c++
Tarble
Messages postés
694
Statut
Membre
-
Tarble Messages postés 694 Statut Membre -
Tarble Messages postés 694 Statut Membre -
Bonjour,
Donc j'apprend le c++, et j'ai crée un petit projet pour m'entrainer mais le problème quand je veut utiliser un objet, il me retourne cette erreur: undefined reference to Temps::Temps()
Voila mes 3 fichier
main.cpp:
#include <iostream>
#include "time.h"
using namespace std;
int main()
{
Temps chrono;
return 0;
}
time.cpp:
#include "time.h"
using namespace std;
Temps::Temps() : m_heure(0), m_min(0), m_sec(0)
{
}
Temps::Temps(int heure, int min, int sec) : m_heure(heure), m_min(min), m_sec(sec)
{
}
int Temps::convert_sec(int heure, int min, int sec)
{
m_heure = heure;
m_min = min;
m_sec = sec;
m_result = (m_heure*3600)+(m_minute*60)+m_sec;
return m_result;
}
time.h:
#ifndef TIME_H_INCLUDED
#define TIME_H_INCLUDED
class Temps
{
public:
Temps();
Temps(int heure, int min, int sec);
int convert_sec(int heure, int min, int sec);
private:
int m_heure;
int m_min;
int m_sec;
int m_result;
};
#endif // TIME_H_INCLUDED
Voilà, merci pour votre aide.
Donc j'apprend le c++, et j'ai crée un petit projet pour m'entrainer mais le problème quand je veut utiliser un objet, il me retourne cette erreur: undefined reference to Temps::Temps()
Voila mes 3 fichier
main.cpp:
#include <iostream>
#include "time.h"
using namespace std;
int main()
{
Temps chrono;
return 0;
}
time.cpp:
#include "time.h"
using namespace std;
Temps::Temps() : m_heure(0), m_min(0), m_sec(0)
{
}
Temps::Temps(int heure, int min, int sec) : m_heure(heure), m_min(min), m_sec(sec)
{
}
int Temps::convert_sec(int heure, int min, int sec)
{
m_heure = heure;
m_min = min;
m_sec = sec;
m_result = (m_heure*3600)+(m_minute*60)+m_sec;
return m_result;
}
time.h:
#ifndef TIME_H_INCLUDED
#define TIME_H_INCLUDED
class Temps
{
public:
Temps();
Temps(int heure, int min, int sec);
int convert_sec(int heure, int min, int sec);
private:
int m_heure;
int m_min;
int m_sec;
int m_result;
};
#endif // TIME_H_INCLUDED
Voilà, merci pour votre aide.
A voir également:
- Problème avec class en c++
- Realtek audio admin background process class ✓ - Forum Wordpress
- Message d'erreur à chaque démarrage ! ✓ - Forum Windows
- Problème bluetooth mercedes classe a - Forum Mobile
- Wrong elf class: elfclass64 - Forum Autres distributions Linux
- Nswrtmon microsoft base class application ✓ - Forum Virus