[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 675
  • Last Modified:

error C2558: class 'std::basic_ifstream<_elem, _Traits>' : no copy constructor available or copy constructor is declared 'explicit'

Hi again,
When I now try to compile my code, I got the following error message:
error C2558: class 'std::basic_ifstream<_elem, _Traits>' : no copy constructor available or copy constructor is declared 'explicit'

Here's the code that doesn't compile now. I've put the "wrong" line between two lines like this: //--------------------------

//*************************** BEGINNING OF THE CODE
// edlaaf.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "cTimeCode.h"
#include "cEdlData.h"
#include "cToken.h"
#include "cLine.h"
#include "cEdl.h"
#include "cAafEdl.h"

const wchar_t* VersionString = L"21.1";
const unsigned int NumAudioChannels = NUM_AUDIO_CHANNELS;

wstring widen(const string & str) throw()
{
  const ctype<wchar_t>& char_facet = _USE(locale(),ctype<wchar_t>);
  wstring ret;
  ret.reserve(str.size());//avoid incremental allocation
  for(string::const_iterator it = str.begin(); it != str.end(); ++it)
  {
    ret += char_facet.widen(*it);
  }
  return ret;
}

int main(int argc, char* argv[])
{
  wcout << L"EDL to AAF converter. Version " << VersionString << L". Num Audio Channels = " << NumAudioChannels << endl;
  wcerr << L"EDL to AAF converter. Version " << VersionString << L". Num Audio Channels = " << NumAudioChannels << endl;

  if(argc != 3)
  {
    wcerr << L"Usage:\n\tedlaaf n file\nWhere:\n";
    wcerr << L"\tn is the edl fps (including the source material 1001 flag i.e. 30, 29.97, 25, 24, 23.98)\n";
    wcerr << L"\tfile is the edl file to convert (without the file extension)\n";
    return -1;
  }

  istringstream str(argv[1]);
  float fps = 0;
  str >> fps;

  if(fps != 30.00f &&
     fps != 29.97f &&
     fps != 25.00f &&
     fps != 24.00f &&
     fps != 23.98f)
  {
    wcerr << L"Error: Acceptable frames rates are: 30, 29.97, 25, 24 or 23.98\n";
    return -1;
  }

  string edlname(argv[2]);
  edlname += ".edl";

//------------------------------------------
wistream& in = wifstream(edlname.c_str());
//------------------------------------------
  if(in.fail())
  {
    wcerr << L"Error: Failed to open file " << widen(edlname.c_str()) << endl;
    return -1;
  }

  cAafEdl::Ptr data = new cAafEdl(fps);
  cEdl edl(data);

  wstring buffer;
  do {
    getline(in,buffer,in.widen('\n'));
    edl.addline(buffer);
  } while(in.good());

  edl.print();
  wcout << L"\n";

  edl.process();

  wstring aafname(widen(argv[2]));
  aafname += L".aaf";
  try
  {
    data->createAaf(aafname);
  }
  catch(HRESULT& hr)
  {
    if(AAFRESULT_FILE_EXISTS == hr)
    {
      wcerr << L"Error: " << aafname << L" already exists" << endl;
    }
    else
    {
      wcerr << L"Error: 0x" << hex << hr << L" while creating aaf file " << aafname << endl;
    }
  }

  return 0;
}

//*************************** END OF THE CODE

Thanks for your help
0
racineconde
Asked:
racineconde
  • 3
  • 2
1 Solution
 
rajeev_devinCommented:
>> wistream& in = wifstream(edlname.c_str());
do this
wifstream in("file_name.txt");
0
 
rajeev_devinCommented:
Sorry this
wifstream in(edlname.c_str());
0
 
racinecondeAuthor Commented:
Hi Rajeev,
Can you please explain me the difference (if you got some time)? I'm a beginner in C++ (two weks) and any explanation is highly welcome...
Thanks again (you all) for your EFFICIENT help...

Regards,

Racine
0
 
rajeev_devinCommented:
wistream& in = wifstream(edlname.c_str());
If you are using this
then wifstream(edlname.c_str()); create an object of class wifstream.
And if you are expecting it to return something then it won't return.
Constructor has no return type :)

wistream& in = wifstream(edlname.c_str());
But this can be done if wifstream has a copy constructor.
0
 
racinecondeAuthor Commented:
Thanks very much for your time Rajeev...

Racine.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now