Squeeker 23 Newbie Poster

Thank you all for your insight!

Squeeker 23 Newbie Poster

So is a literal anything inside of quotation marks?

Squeeker 23 Newbie Poster

ARGH! A literal string is just a C-String. Curse you silly vernacular! Thanks for the help Ancient, as always you are awesome.

Squeeker 23 Newbie Poster

I am studying for a C++ exam and the study guide says "Be able to initialize arrays using literal arrays." Ok then, so I think well yeah that is easy, a literal array is something like.....Wait, I have no idea what a literal array is! From what I can find (on the web) a "literal" is a constant and whose values are implied by their representations. I got that from this website: http://cpp.comsci.us/etymology/literals.html

This is still on clear to me, what is a literal? What is a literal array? What is the significance of a literal array? I would really like to be clear on this before I go in for my exam. Could someone please point me in the right direction.

Thanks,
Arielle

Squeeker 23 Newbie Poster

Nevermind, I got it. Thanks.

Squeeker 23 Newbie Poster

Hello all,

I have an assignment to create a base class for a vector. Now after reading through the instructions I am still unclear the instructions. I am NOT asking for you to do my homework! I just need some clarification. PLEASE DO NOT POST ANY CODE!

Here is a snippet of the assignment text:

Suppose that vectors were not defined in C++. Define a class called VectorDouble that is like a class for a vector with base type of double......Your class should have all of the following:
*Three constructors: a default constructor that creates a dynamic array for 50 elements........
*Member functions push_back, capacity...and size that behave the same as the member functions of the same names for vectors......
*Two member functions to give your class the same utility as the square brackets: value_at(i), which returns the value of the ith element in the dynamic array; and change_value_at(d,i) which changes the double value at the ith element of the dynamic array to d. Enforce suitable restrictions on the arguments to value_at(i) and change_value_at. (Your class will not work with the square bracket. It can be made to work with square bracket, but we have not covered the material which tells you how to do that.)

My question is does this mean I am not going to be using any vectors but rather dynamic arrays?

Squeeker 23 Newbie Poster

Ahhh, I see. Thank you very much! The brownies are en route to the rendezvous check point.

Squeeker 23 Newbie Poster

You can, but a better question is should you? Do it however your instructor/professor and/or textbook suggests. In some cases you may not need an implementation file at all -- when everything is inline in the interface file.

I am doing this on my own accord, my textbook doesn't say I should even break it up and neither does my professor. I am just doing it for practice.

I thought that the interface file was where you wrote all your function declarations, and the implementation file was for all your function declarations. So I am not understanding what you are saying about:

In some cases you may not need an implementation file at all -- when everything is inline in the interface file.

Please explain.

Squeeker 23 Newbie Poster

Thank you for explaining and as soon as we have the stargate up and working i will send those brownies.

One last question, if I separate my classes into two interface files can I use the same implementation file? I am pretty sure I can but not certain...

Squeeker 23 Newbie Poster

Is this a test question? How many browney points do I get for answering it :)

No this is not a test question. I am about to start my homework which is write a program that has an exception class and another class and I want to split up the program into application, implementation, and interface files to practice last weeks lesson that taught us about splitting them all up.

For being an awesome guy who responds to all of my questions whenever I post on daniweb I will make you some brownies and mail them to you, but I am not a commander of brownie points and thus cannot give any to you.

Squeeker 23 Newbie Poster

Can an Interface file contain multiple classes? If so how would one implement this interface file (what specifications do you need to use to specify which class you are using)?

If this is not legal or is a bad programming practice then please explain why.

Thank you,
Arielle

Squeeker 23 Newbie Poster

Thanks a million!

Squeeker 23 Newbie Poster

I thought it was "legal" to mix parameter lists.

Also thanks for the quick reply :)

Squeeker 23 Newbie Poster

Are call by reference functions of type int or double legal when using an ifstream or ostream argument?

Example:

int afunction(ifstream& in, int anumber)
{
/* Function Body */
}

If this is/isn't legal please explain. Thank you for your help.

-Arielle

Squeeker 23 Newbie Poster

Thank you for all the pointers everyone. I really appreciate it.
-Arielle

Squeeker 23 Newbie Poster

Hello all,

I am working on a program that takes input from a file, removes extra white spaces and outputs the edited text to another file.

So far my program deletes 1 whitespace whether the whitespace should be deleted or not.

I have read about peek() and putback(). I am pretty sure I need to implement these two functions but quite frankly I am not sure how to go about doing this.

I don't want anyone to just give me the answer I would really appreciate it if someone gave me a hint as to where my logic went south or my structure or enlighten me about some predefined function you think I may not be aware of.

Any help is appreciated. Thank you.
-Arielle

#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdlib>

using namespace std;
void check_blank(ifstream& instream, ofstream& outstream);
int number = 0; //keeps track of how many spaces have been deleted

int main() 
{
  ifstream instream;
  ofstream outstream;
  bool     t;
  
  instream.open("hw4pr6input.txt");         //Open file: text to be edited
  if(!instream.fail())                      //Make sure file opened successfully
  {
  cout << "test from open";
     //Call function that finds blanks and edits
  }
  else
  {
    cout << "File failed to open (1st)";
    exit(1);
  }
  
  outstream.open("hw4pr6output.txt");       //Open file: edited text will go
  if(!outstream.fail())                     //Check if open failed
  {
   t = true;   
   check_blank(instream, outstream);              //Call function to input edited text into file
  }
  else
  {
    cout << "File failed to open (2nd)";
    exit(1);  
  }
  
  cout << "Removed " …
Ancient Dragon commented: Great going with code tags :) +23