#3529
oop_1
C++
Pentru o clasă C++ dată, scrieți definiția completă a funcției membre Suma
care returnează suma celor două variabile membre ale clasei.
Folclorul informatic
Problema | oop_1 | Operații I/O |
![]() oop_1.in /oop_1.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #57654218 | Utilizator | |
Fișier | oop_1.cpp | Dimensiune | 1.68 KB |
Data încărcării | 09 Aprilie 2025, 11:01 | Scor / rezultat | Eroare de compilare |
oop_1.cpp:17:7: error: expected nested-name-specifier before 'namespace' using namespace std; ^ oop_1.cpp:17:7: error: expected unqualified-id before 'namespace' oop_1.cpp:17:7: error: expected ';' before 'namespace' oop_1.cpp:17:7: error: expected unqualified-id before 'namespace' oop_1.cpp:44:21: error: cannot define member function 'A::comp::citire' within 'A' void comp :: citire() ^ oop_1.cpp:52:21: error: cannot define member function 'A::comp::afisare' within 'A' void comp:: afisare() ^ oop_1.cpp:57:33: error: expected ')' before ';' token istream operator >>(istream & is; comp &z) ^ oop_1.cpp:57:41: error: expected ';' at end of member declaration istream operator >>(istream & is; comp &z) ^ oop_1.cpp:57:42: error: expected unqualified-id before ')' token istream operator >>(istream & is; comp &z) ^ oop_1.cpp:63:42: error: 'std::ostream A::operator<<(std::ostream&, A::comp&)' must take exactly one argument ostream operator <<(ostream& os, comp & z) ^ oop_1.cpp:73:23: error: cannot define member function 'A::comp::comp' within 'A' comp :: comp (comp & x) ^ oop_1.cpp:82:37: error: 'A::comp A::operator+(A::comp&, A::comp&)' must take either zero or one argument comp operator +(comp & z1, comp & z2) ^ oop_1.cpp:91:37: error: 'A::comp A::operator-(A::comp&, A::comp&)' must take either zero or one argument comp operator -(comp & z1, comp & z2) ^ oop_1.cpp:100:37: error: 'A::comp A::operator/(A::comp&, A::comp&)' must take exactly one argument comp operator /(comp & z1, comp & z2) ^ oop_1.cpp: In constructor 'A::A(int, int)': oop_1.cpp:9:5: error: uninitialized reference member 'A::z' [-fpermissive] A(int _a, int _b) ^ oop_1.cpp: In member function 'float A::comp::modul()': oop_1.cpp:24:32: error: no matching function for call to 'sqrt(float, float)' return sqrt(re*re,im*im); ^ oop_1.cpp:24:32: note: candidates are: In file included from /usr/include/features.h:374:0, from /usr/include/assert.h:35, from /usr/include/c++/4.8/cassert:43, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:33, from oop_1.cpp:1: /usr/include/i386-linux-gnu/bits/mathcalls.h:156:1: note: double sqrt(double) __MATHCALL (sqrt,, (_Mdouble_ __x)); ^ /usr/include/i386-linux-gnu/bits/mathcalls.h:156:1: note: candidate expects 1 argument, 2 provided In file included from /usr/include/c++/4.8/valarray:587:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:94, from oop_1.cpp:1: /usr/include/c++/4.8/bits/valarray_after.h:455:5: note: template<class _Tp> std::_Expr<std::_UnClos<std::_Sqrt, std::_ValArray, _Tp>, _Tp> std::sqrt(const std::valarray<_Tp>&) _DEFINE_EXPR_UNARY_FUNCTION(sqrt, _Sqrt) ^ /usr/include/c++/4.8/bits/valarray_after.h:455:5: note: template argument deduction/substitution failed: oop_1.cpp:24:32: note: mismatched types 'const std::valarray<_Tp>' and 'float' return sqrt(re*re,im*im); ^ In file included from /usr/include/c++/4.8/valarray:587:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:94, from oop_1.cpp:1: /usr/include/c++/4.8/bits/valarray_after.h:455:5: note: template<class _Dom> std::_Expr<std::_UnClos<std::_Sqrt, std::_Expr, _Dom>, typename _Dom::value_type> std::sqrt(const std::_Expr<_Dom1, typename _Dom1::value_type>&) _DEFINE_EXPR_UNARY_FUNCTION(sqrt, _Sqrt) ^ /usr/include/c++/4.8/bits/valarray_after.h:455:5: note: template argument deduction/substitution failed: oop_1.cpp:24:32: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'float' return sqrt(re*re,im*im); ^ In file included from /usr/include/c++/4.8/ccomplex:38:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from oop_1.cpp:1: /usr/include/c++/4.8/complex:892:5: note: template<class _Tp> std::complex<_Tp> std::sqrt(const std::complex<_Tp>&) sqrt(const complex<_Tp>& __z) { return __complex_sqrt(__z.__rep()); } ^ /usr/include/c++/4.8/complex:892:5: note: template argument deduction/substitution failed: oop_1.cpp:24:32: note: mismatched types 'const std::complex<_Tp>' and 'float' return sqrt(re*re,im*im); ^ In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:41:0, from oop_1.cpp:1: /usr/include/c++/4.8/cmath:494:5: note: template<class _Tp> constexpr typename __gnu_cxx::__enable_if<std::__is_integer<_Tp>::__value, double>::__type std::sqrt(_Tp) sqrt(_Tp __x) ^ /usr/include/c++/4.8/cmath:494:5: note: template argument deduction/substitution failed: oop_1.cpp:24:32: note: candidate expects 1 argument, 2 provided return sqrt(re*re,im*im); ^ In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:41:0, from oop_1.cpp:1: /usr/include/c++/4.8/cmath:486:3: note: constexpr long double std::sqrt(long double) sqrt(long double __x) ^ /usr/include/c++/4.8/cmath:486:3: note: candidate expects 1 argument, 2 provided /usr/include/c++/4.8/cmath:482:3: note: constexpr float std::sqrt(float) sqrt(float __x) ^ /usr/include/c++/4.8/cmath:482:3: note: candidate expects 1 argument, 2 provided oop_1.cpp: In function 'int main()': oop_1.cpp:126:16: error: 'class A' has no member named 'Suma' fout << ob.Suma() << "\n"; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema oop_1 face parte din a doua categorie. Pentru aceste probleme se folosește un program suport, furnizat de propunătorul problemei. Soluția propusă de tine va fi evaluată astfel:
Suma punctajelor acordate pe testele utilizate pentru verificare este 100. Astfel, soluția ta poate obține cel mult 100 de puncte, caz în care se poate considera corectă.