Přidat otázku mezi oblíbenéZasílat nové odpovědi e-mailem c++ virtualne funkcie

Nemam momentalne lib, zatial je to len vo vyvoji tak pouzivam priamo cpp subory, viem ze je ich viac a su to moje triedy ziadna ina lib. Posielam priklad na jednoduchsej triede, na tej to budem riesit tie ostatne su moc komplikovane nechce sa mi to cele rozpisovat. Vyzera asi takto:

ACGroupState.hpp

#ifndef ACGROUPSTATE_HPP
#define	ACGROUPSTATE_HPP
#include <list>

//template<class valueType, class valueAccessor>
class ACGroupState  
{
    public:
        bool checkStates();
        
    public:
        ACGroupState(){};
};

#endif	/* ACGROUPSTATE_HPP */

ACGroupState.cpp
#include "ACGroupState.hpp"

//template<class valueType, class valueAccessor>
bool ACGroupState/*<valueType, valueAccessor>*/::checkStates()
{
}

main.cpp

#include <cstdlib>
#include "../reporty/stateReports/ACGroupState.hpp"
#include "../../worker_new/includes/JSONcpp/json/json.h"
using namespace std;

/*
 * 
 */
int main(int argc, char** argv) {
    ACGroupState/*<double, double>*/ test;
    test.checkStates();
    return 0;
}


Samozrejme je nedopisana, nema zatial zmysel pokracovat. Ten public je tam dva krat lebo ten prvy krat to bolo private. Ma to byt sablonova trieda, a ked to skompilujem ako sablonu tak v tedy mi nenajde referenciu na checkState(). Ked ale template zakomentujem tak ako je to teraz, v pohode ju skompilujem a aj program zbehne bez problemov ziadna chyba. Ked ale template vsade odkomentujem tak dostanem toto:
Copying project files to /home/kardos/.netbeans/remote/192.168.137.150/test-server-Windows-x86_64/ at kardos@192.168.137.150:22
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/home/kardos/.netbeans/remote/192.168.137.150/test-server-Windows-x86_64/F/temp_projects/reporty/NewReports'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/newreports
make[2]: Entering directory `/home/kardos/.netbeans/remote/192.168.137.150/test-server-Windows-x86_64/F/temp_projects/reporty/NewReports'
mkdir -p build/Debug/GNU-Linux-x86
rm -f build/Debug/GNU-Linux-x86/main.o.d
g++    -c -g -I../../worker_new/includes/JSONcpp -MMD -MP -MF build/Debug/GNU-Linux-x86/main.o.d -o build/Debug/GNU-Linux-x86/main.o main.cpp
make[2]: Warning: File `../reporty/stateReports/ACGroupState.cpp' has modification time 3.4e+06 s in the future
mkdir -p build/Debug/GNU-Linux-x86/_ext/379575527
rm -f build/Debug/GNU-Linux-x86/_ext/379575527/ACGroupState.o.d
g++    -c -g -I../../worker_new/includes/JSONcpp -MMD -MP -MF build/Debug/GNU-Linux-x86/_ext/379575527/ACGroupState.o.d -o build/Debug/GNU-Linux-x86/_ext/379575527/ACGroupState.o ../reporty/stateReports/ACGroupState.cpp
mkdir -p dist/Debug/GNU-Linux-x86
g++     -o dist/Debug/GNU-Linux-x86/newreports build/Debug/GNU-Linux-x86/_ext/663172118/json_reader.o build/Debug/GNU-Linux-x86/main.o build/Debug/GNU-Linux-x86/_ext/379575527/ACGroupState.o build/Debug/GNU-Linux-x86/_ext/663172118/json_writer.o build/Debug/GNU-Linux-x86/_ext/663172118/json_value.o  
build/Debug/GNU-Linux-x86/main.o: In function `main':
/home/kardos/.netbeans/remote/192.168.137.150/test-server-Windows-x86_64/F/temp_projects/reporty/NewReports/main.cpp:22: undefined reference to `ACGroupState<double, double>::checkStates()'
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-Linux-x86/newreports] Error 1
make[2]: Leaving directory `/home/kardos/.netbeans/remote/192.168.137.150/test-server-Windows-x86_64/F/temp_projects/reporty/NewReports'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/home/kardos/.netbeans/remote/192.168.137.150/test-server-Windows-x86_64/F/temp_projects/reporty/NewReports'
make: *** [.build-impl] Error 2


BUILD FAILED (exit value 2, total time: 6s)
Je na tom nieco zle?

Reakce na odpověď

1 Zadajte svou přezdívku:
2 Napište svou odpověď:
3 Pokud chcete dostat ban, zadejte libovolný text:

Zpět do poradny