Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8513439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:34:11+00:00 2026-06-11T04:34:11+00:00

Just a really quick question here. I’m using virtual functions to read in from

  • 0

Just a really quick question here. I’m using virtual functions to read in from a text file. Now, it’s virtual because in one aspect I want the values to be normalised, and, in the other respect I don’t want them to be normalised. I have tried to do this:

bool readwav(string theFile, 'native');

So in theory, if the ‘native’ is used, this method should be called, however, if ‘double’ is called then a different version of the method is called. Same for if the value is empty, it should just perform the native option.

First question, why doesn’t the declaration above work? Also, is this the best route to go down? Or, would it be better to have just one class method that switches between the options.

Thanks 🙂

Update:

Where am I going wrong?

bool Wav::readwav(string theFile, ReadType type = NATIVE)
{
// Attempt to open the .wav file
ifstream file (theFile.c_str());

if(!this->readHeader(file))
{
    cerr << "Cannot read header file";
    return 0;
}

for(unsigned i=0; (i < this->dataSize); i++)
{
    float c = (unsigned)(unsigned char)data[i];

    this->rawData.push_back(c);
}

return true;
}

bool Wav::readwav(string theFile, ReadType type = DOUBLE)
{
  // Attempt to open the .wav file
  ifstream file (theFile.c_str());

  cout << "This is the double information";
  return true;
 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:34:12+00:00Added an answer on June 11, 2026 at 4:34 am

    Sounds like what you want is an enumeration with a default parameter.

    enum FileType
    {
      NATIVE=0,
      DOUBLE      
    };
    
    bool readwav(string theFile, FileType type = NATIVE);
    

    Default parameters are present in the function declaration, do not put them in the definition.

    bool readwav(string theFile, FileType type)
    {
      switch(type)
      {
        case NATIVE: { ... } break;
        case DOUBLE: { ... } break;
        default: { ... } break;
      }
    }
    

    This way, calling readwav without a parameter will use the NATIVE type by default.

    readwav("myfile.wav"); // Uses NATIVE type
    readwav("myfile.wav", NATIVE); // Also uses NATIVE
    readwav("myfile.wav", DOUBLE); // Uses DOUBLE type
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using EF4. Just a quick question, is this a really good framework?
Just a really quick question relating to GitHubs function to take a README file
Just a quick question really: I'm running a method to pull records from an
Just a quick question because I really can't find a simple solution to my
Really quick here... I think I have the answer, but just looking for some
Just a quick question. In WP7, is it really bad design/idea to store complex
Coming from Question which was answered really quick, I have stumbled upon upgraded problem.
Just a really quick question about something small. The following is part of a
Just a quick question really. I am re-writing a site and I am converting
I really just want to do something like x <- as.integer(c(1,2,3)) But because c(1,2,3)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.