Ez miért nem fordul le? Mi a hiba?
//main.cpp
# include <iostream>
# include <stdlib.h>
typedef unsigned short ushort;
typedef unsigned int uint;
using std::cout;
using std::cin;
using std::endl;
class SIMPLECAT
{
public:
SIMPLECAT();
SIMPLECAT(const SIMPLECAT&);
~SIMPLECAT();
int GetAge()const {return *itsAge;}
int GetWeight()const {return *itsWeight;}
void SetAge(int age) {*itsAge = age;}
private:
int *itsAge;
int *itsWeight;
};
SIMPLECAT::SIMPLECAT()
{
cout <<"Konstruktor \n";
itsAge = new int;
itsWeight = new int;
*itsAge = 4;
*itsWeight = 8;
}
SIMPLECAT::SIMPLECAT(const SIMPLECAT &rhs)
{
cout <<"Copy Konstruktor \n";
itsAge = new int;
itsWeight = new int;
*itsAge = rhs.GetAge();
*itsWeight = rhs.GetWeight();
}
SIMPLECAT::~SIMPLECAT()
{
cout <<"Destruktor \n";
delete itsAge;
itsAge = NULL;
delete itsWeight;
itsWeight = NULL;
}
int main()
{
SIMPLECAT Bolyhos;
cout <<"Bolyhos s age "<< Bolyhos.GetAge <<" years old \n"
<<"Setting Bolyhos to 6 ... \n";
Bolyhos.SetAge(6);
cout <<"Creating Boots from Bolyhos \n";
SIMPLECAT Boots(Bolyhos);
cout <<"Bolyhos s age: "<< Bolyhos.GetAge() << endl
<<"Boots s age: "<< Boots.GetAge() << endl;
Bolyhos.SetAge(7);
cout <<"Bolyhos s age: "<< Bolyhos.GetAge() << endl
<<"Boots s age: "<< Boots.GetAge() << endl;
return EXIT_SUCCESS;
}
//Hibaüzenetből meg van egy millió:
||=== Practice_5, Debug ===|
C:\Users\ALWAYS_WINS\Desktop\Code Blocks mentesek\Practice_5\main.cpp||In function 'int main()':|
C:\Users\ALWAYS_WINS\Desktop\Code Blocks mentesek\Practice_5\main.cpp|59|error: no match for 'operator<<' in 'std::operator<< [with _Traits = std::char_traits<char>]((* & std::cout), ((const char*)"Bolyhos s age ")) << Bolyhos.SIMPLECAT::GetAge'|
C:\Users\ALWAYS_WINS\Desktop\Code Blocks mentesek\Practice_5\main.cpp|59|note: candidates are:|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|110|note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ostream_type& (*)(std::basic_ostream<_CharT, _Traits>::__ostream_type&)) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|110|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&) {aka std::basic_ostream<char>& (*)(std::basic_ostream<char>&)}'|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|119|note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ios_type& (*)(std::basic_ostream<_CharT, _Traits>::__ios_type&)) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>, std::basic_ostream<_CharT, _Traits>::__ios_type = std::basic_ios<char>]|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|119|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&) {aka std::basic_ios<char>& (*)(std::basic_ios<char>&)}'|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|129|note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|129|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::ios_base& (*)(std::ios_base&)'|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|167|note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|167|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long int'|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|171|note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|171|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long unsigned int'|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|175|note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|175|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'bool'|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\bits\ostream.tcc|93|note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char, _Traits = std::char_traits<char>]|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\bits\ostream.tcc|93|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short int'|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|182|note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|182|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short unsigned int'|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\bits\ostream.tcc|107|note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char, _Traits = std::char_traits<char>]|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\bits\ostream.tcc|107|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'int'|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|193|note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|193|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'unsigned int'|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|202|note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|202|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long int'|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|206|note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|206|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long unsigned int'|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|211|note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|211|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'double'|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|215|note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|215|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'float'|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|223|note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|223|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long double'|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|227|note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|227|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const void*'|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\bits\ostream.tcc|121|note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__streambuf_type*) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__streambuf_type = std::basic_streambuf<char>]|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\bits\ostream.tcc|121|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__streambuf_type* {aka std::basic_streambuf<char>*}'|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|528|note: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const unsigned char*)|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|523|note: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const signed char*)|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|510|note: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const char*)|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\bits\ostream.tcc|323|note: template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const char*)|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|493|note: template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const _CharT*)|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|473|note: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, unsigned char)|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|468|note: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, signed char)|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|462|note: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, char)|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|456|note: template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, char)|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|451|note: template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, _CharT)|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\bits\basic_string.h|2694|note: template<class _CharT, class _Traits, class _Alloc> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&)|
||=== Build finished: 47 errors, 0 warnings ===|
cout <<"Bolyhos s age "<< Bolyhos.GetAge <<" years old \n"<<"Setting Bolyhos to 6 ... \n";
hiányzik a () a GetAge mögül
Itt miért hívódik meg 2 szer a destruktor?
Azért mert a Bolyhost törli: egyszer destruktor.
Azért mert a Bootsot törli: még egyszer destruktor.
Ezért hívódik meg kétszer a végén a destruktor?
Kapcsolódó kérdések:
Minden jog fenntartva © 2024, www.gyakorikerdesek.hu
GYIK | Szabályzat | Jogi nyilatkozat | Adatvédelem | Cookie beállítások | WebMinute Kft. | Facebook | Kapcsolat: info(kukac)gyakorikerdesek.hu
Ha kifogással szeretne élni valamely tartalommal kapcsolatban, kérjük jelezze e-mailes elérhetőségünkön!