fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Generator {
  5. public:
  6. virtual float getSample(int sample)=0;
  7. };
  8.  
  9. class Note {
  10. public:
  11.  
  12. Generator *generator; // THIS IS WHAT IS CAUSING ME TROUBLE
  13. Note(Generator *aGen){
  14. generator = aGen;
  15. }
  16. };
  17.  
  18. class Synth : public Generator{
  19. public:
  20. virtual float getSample(int sample);
  21. int varA;
  22. int varB;
  23. Synth(){
  24. varA = 5;
  25. varB = 8;
  26. }
  27. };
  28.  
  29.  
  30. float Synth::getSample(int sample){
  31. varA = sample;
  32. varB = 3;
  33.  
  34. return 0;
  35. }
  36.  
  37. class Track {
  38. public:
  39. Generator *generator;
  40. Track(){
  41. generator = new Synth();
  42. }
  43. };
  44.  
  45. int main() {
  46. cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
  47. Track track = Track();
  48. Note n = Note(&track.generator);
  49. cout << "test" << endl;
  50. return 0;
  51. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:48:35: error: no matching function for call to ‘Note::Note(Generator**)’
prog.cpp:48:35: note: candidates are:
prog.cpp:13:5: note: Note::Note(Generator*)
prog.cpp:13:5: note:   no known conversion for argument 1 from ‘Generator**’ to ‘Generator*’
prog.cpp:9:7: note: Note::Note(const Note&)
prog.cpp:9:7: note:   no known conversion for argument 1 from ‘Generator**’ to ‘const Note&’
prog.cpp:48:10: warning: unused variable ‘n’ [-Wunused-variable]
stdout
Standard output is empty