Error C2248 - Clueless

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jul 2009
Posts: 53
Reputation: Nogat21 is an unknown quantity at this point 
Solved Threads: 0
Nogat21 Nogat21 is offline Offline
Junior Poster in Training

Error C2248 - Clueless

 
0
  #1
Aug 11th, 2009
Hey All, i'm doing this project in c++ consisting in reading an mp3 file and extracting the informations within it. Thing is i'm starting to be pissed by this persistent error that stops me from test the code.

This error is, as far as my (limited) knowledge goes, caused by the passing of a stream parameter to a function by copy. Considering that, i'm passing the parameters by reference, but still the error subsists...

I would be very grateful if someone give me a hand here. Thanks in advance, here's the code:

header :

  1.  
  2. #endif
  3.  
  4. #ifndef VISITOR_H
  5. #define VISITOR_H
  6.  
  7. #include <stdio.h>
  8. #include <sstream>
  9. #include <fstream>
  10. #include <list>
  11.  
  12. using namespace std;
  13.  
  14. class FrameVisitor : public Frame
  15. {
  16. list<Frame> frames;
  17.  
  18. public:
  19.  
  20. FrameVisitor();
  21. list<Frame> get_frames(fstream& file);
  22. bool getFirstFrame(Frame& f);
  23. void WriteFrame(Frame f, FILE * dst);
  24. int fastValidation(Frame f);
  25.  
  26. };
  27.  
  28. #endif

implementation:

  1.  
  2. #include "Mp3.h"
  3.  
  4. using namespace std;
  5.  
  6. FrameVisitor::FrameVisitor()
  7. {
  8. Frame();
  9. frames = get_frames(myfile);
  10. }
  11.  
  12. void FrameVisitor::WriteFrame(Frame f, FILE * dst)
  13. {
  14. size_t num_bytes = f.getLength(); //size_t size var de instancia de Frame.
  15. memcpy(dst,f.frame,num_bytes);
  16.  
  17. //Duvida: É preciso criar um novo file com o mm nome, escrever la a frame e depois o resto?
  18. //ou basta escrever por cima como tou a fazer aqui?
  19.  
  20. }
  21.  
  22. list<Frame> FrameVisitor::get_frames(fstream& myfile)
  23. {
  24.  
  25. char * memblock = new char [4]; //1º 4 bytes da frame...header.
  26. char * start = memblock;
  27. int i = 0;
  28. char c;
  29. list<Frame> lst;
  30. Frame f;
  31.  
  32. while(!myfile.eof()){
  33.  
  34. while(i<4){
  35.  
  36. c=myfile.get();
  37. f.addByte(c);
  38. memblock[i++]=c;
  39.  
  40. }
  41. myfile.seekg(-4,ios::cur);
  42. i = 0;
  43.  
  44. if((memblock[0] == 0xFF) && ((memblock[1])& 0xE0) == 0xE0)
  45. {
  46. f.getFrame(myfile);//Pedaço do ficheiro ate encontrar prox header.
  47.  
  48. //Construir uma frame para meter na lista.
  49. if(fastValidation(f) == 0)
  50. {
  51.  
  52. lst.push_back((f));
  53. memblock = start;
  54. }
  55. else
  56. {
  57. f.clear();
  58. memblock = start;
  59. myfile.seekg(1,ios::cur);
  60. }
  61. }
  62. myfile.seekg(1,ios::cur);
  63. memblock = start;
  64. f.clear();
  65. }
  66. return lst;
  67. }
  68.  
  69. int FrameVisitor::fastValidation(Frame f)
  70. {
  71.  
  72. if((f.getVersion() ==1) || (f.getLayer() == 0) || (f.getBitrate() == 0 || f.getBitrate() == 15) || (f.getFrequency() == 3))
  73. return -1;
  74. return 0;
  75.  
  76. }
  77.  
  78. bool FrameVisitor::getFirstFrame(Frame& f)
  79. {
  80. if(!frames.empty())
  81. {
  82. f = frames.front();
  83. return true;
  84. }
  85. return false;
  86. }

The error message goes:

1>------ Build started: Project: Trabalho2, Configuration: Debug Win32 ------
1>Compiling...
1>Mp3.cpp
1>FrameVisitor.cpp
1>c:\program files\microsoft visual studio 8\vc\include\fstream(933) : error C2248: 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 8\vc\include\ios(151) : see declaration of 'std::basic_ios<_Elem,_Traits>::basic_ios'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> This diagnostic occurred in the compiler generated function 'std::basic_fstream<_Elem,_Traits>::basic_fstream(const std::basic_fstream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1>Generating Code...
1>Build log was saved at "file://c:\Users\Bruno\Desktop\ISEL\PICC\Trabalhos\Trabalho2\Trabalho2\Debug\BuildLog.htm"
1>Trabalho2 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Last edited by Nogat21; Aug 11th, 2009 at 11:19 am.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 1,120
Reputation: firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice 
Solved Threads: 143
firstPerson's Avatar
firstPerson firstPerson is offline Offline
Veteran Poster

Re: Error C2248 - Clueless

 
1
  #2
Aug 11th, 2009
which line does it point to?
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 53
Reputation: Nogat21 is an unknown quantity at this point 
Solved Threads: 0
Nogat21 Nogat21 is offline Offline
Junior Poster in Training

Re: Error C2248 - Clueless

 
0
  #3
Aug 11th, 2009
It points directly to fstream. It doesnt indicate in which line of my code the error occurs
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 147
Reputation: Laiq Ahmed will become famous soon enough Laiq Ahmed will become famous soon enough 
Solved Threads: 20
Laiq Ahmed Laiq Ahmed is offline Offline
Junior Poster

Re: Error C2248 - Clueless

 
0
  #4
Aug 11th, 2009
I've few questions,

  1. FrameVisitor::FrameVisitor()
  2. {
  3. Frame();
  4. frames = get_frames(myfile);
  5. }
you have passed 'myfile' as a parameter in fstream where it is defined?

change the following Code.
  1. list<Frame> FrameVisitor::get_frames(fstream& myfile)
  2. {
  3.  
  4. char * memblock = new char [4]; //1º 4 bytes da frame...header.
  5. char * start = memblock;
  6. int i = 0;
  7. char c;
  8. list<Frame> lst;
  9. ...........
  10. }
  11.  
  12. // to the below one.
  13. list<Frame> FrameVisitor::get_frames(const char* myfilePath)
  14. {
  15. fstream myfile(myfilePath, ios::in);
  16. char * memblock = new char [4]; //1º 4 bytes da frame...header.
  17. char * start = memblock;
  18. int i = 0;
  19. char c;
  20. list<Frame> lst;
  21. ...........
  22.  
  23. }

Try to pass the filePath not the streams between functions
just open the stream where required and close it after using.

as far as the problem is concerned there is no copy constructor defined for streams, whenever pass by value they'll cause problems.
check your code of class frame as well. rather than storing the stream as a member keep the file path as a member.

Hope this helps.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 1,120
Reputation: firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice 
Solved Threads: 143
firstPerson's Avatar
firstPerson firstPerson is offline Offline
Veteran Poster

Re: Error C2248 - Clueless

 
0
  #5
Aug 11th, 2009
Last edited by firstPerson; Aug 11th, 2009 at 12:01 pm.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 53
Reputation: Nogat21 is an unknown quantity at this point 
Solved Threads: 0
Nogat21 Nogat21 is offline Offline
Junior Poster in Training

Re: Error C2248 - Clueless

 
0
  #6
Aug 11th, 2009
Yeah its a good way of avoiding this problem...i'm not very happy with this implementation, im going to start this from scratch. Thanks for your help.

If i have some more doubts and problems i'll open another post.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC