fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. const int rozmiar = 1024;
  6.  
  7. class widmo{
  8. public:
  9. int kanal[rozmiar];
  10.  
  11. widmo(int wart = 0);
  12.  
  13. widmo operator+(int);
  14. };
  15. widmo::widmo(int wart)
  16. {
  17. for(int i = 0 ; i < rozmiar ; i++)
  18. kanal[i] = wart;
  19. }
  20. widmo widmo:: operator+(int liczba){
  21. widmo rezultat;
  22. for(int i = 0 ; i < rozmiar ; i++)
  23. rezultat.kanal[i] = kanal[i] + liczba;
  24. return rezultat;
  25. }
  26.  
  27. int main()
  28. {
  29. widmo kobalt[5];
  30. widmo nowe;
  31. nowe = kobalt + 100;
  32.  
  33. cout << "Przykladowo patrzymy na na kanal 44. \n"
  34. "Widmo 'kobalt' ma tam : "
  35. << kobalt.kanal[44]
  36. << "\na w widmie 'nowe' jest tam : "
  37. << nowe.kanal[44] << endl;
  38.  
  39. nowe = nowe + 700;
  40. cout << "A teraz w kanale 44 obiektu 'nowe' jest :"
  41. << nowe.kanal[44] << endl;
  42. return 0;
  43. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:31:14: error: ambiguous overload for 'operator=' (operand types are 'widmo' and 'widmo*')
         nowe = kobalt + 100;
              ^
prog.cpp:7:7: note: candidate: widmo& widmo::operator=(const widmo&) <near match>
 class widmo{
       ^
prog.cpp:7:7: note:   conversion of argument 1 would be ill-formed:
prog.cpp:31:23: error: invalid user-defined conversion from 'widmo*' to 'const widmo&' [-fpermissive]
         nowe = kobalt + 100;
                       ^
prog.cpp:15:1: note: candidate is: widmo::widmo(int) <near match>
 widmo::widmo(int wart)
 ^
prog.cpp:15:1: note:   conversion of argument 1 would be ill-formed:
prog.cpp:31:23: error: invalid conversion from 'widmo*' to 'int' [-fpermissive]
         nowe = kobalt + 100;
                       ^
prog.cpp:31:23: error: invalid conversion from 'widmo*' to 'int' [-fpermissive]
prog.cpp:15:1: note:   initializing argument 1 of 'widmo::widmo(int)'
 widmo::widmo(int wart)
 ^
prog.cpp:7:7: note: candidate: widmo& widmo::operator=(widmo&&) <near match>
 class widmo{
       ^
prog.cpp:7:7: note:   conversion of argument 1 would be ill-formed:
prog.cpp:31:23: error: invalid user-defined conversion from 'widmo*' to 'widmo&&' [-fpermissive]
         nowe = kobalt + 100;
                       ^
prog.cpp:15:1: note: candidate is: widmo::widmo(int) <near match>
 widmo::widmo(int wart)
 ^
prog.cpp:15:1: note:   conversion of argument 1 would be ill-formed:
prog.cpp:31:23: error: invalid conversion from 'widmo*' to 'int' [-fpermissive]
         nowe = kobalt + 100;
                       ^
prog.cpp:31:23: error: invalid conversion from 'widmo*' to 'int' [-fpermissive]
prog.cpp:15:1: note:   initializing argument 1 of 'widmo::widmo(int)'
 widmo::widmo(int wart)
 ^
prog.cpp:31:14: error: conversion to non-const reference type 'class widmo&&' from rvalue of type 'widmo' [-fpermissive]
         nowe = kobalt + 100;
              ^
prog.cpp:35:27: error: request for member 'kanal' in 'kobalt', which is of non-class type 'widmo [5]'
                 << kobalt.kanal[44]
                           ^
stdout
Standard output is empty