Thank you all for your insight!
Ancient Dragon commented: Great going with code tags :) +23
Thank you all for your insight!
So is a literal anything inside of quotation marks?
ARGH! A literal string is just a C-String. Curse you silly vernacular! Thanks for the help Ancient, as always you are awesome.
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
Nevermind, I got it. Thanks.
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?
Ahhh, I see. Thank you very much! The brownies are en route to the rendezvous check point.
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.
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...
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.
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
Thanks a million!
I thought it was "legal" to mix parameter lists.
Also thanks for the quick reply :)
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
Thank you for all the pointers everyone. I really appreciate it.
-Arielle
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 " …
This course introduces students to the discipline of
computer science, using the C++ programming language
as its tool. Covered topics will include algorithm development,
data representation, logical expressions, sub-procedures
and functions, and input/output operations.
The course will introduce both object-oriented and structured
programming concepts and will emphasize good, professional
programming practices. The course meets the basic standards
of the CS1 course as defined by the Association of Computing
Machinery (ACM). It is consistent with the first computer
science course in a four-year program and should transfer
to most such programs.
This courseintroduces students tothe disciplineof
computer science, usingthe C++programming language
as its tool.Covered topics will includealgorithm development,
data representation,logical expressions, sub-procedures
andfunctions, and input/output operations.
The course willintroduce both object-orientedand structured
programming conceptsand will emphasizegood, professional
programming practices. The coursemeets thebasic standards
of theCS1 courseas definedby theAssociation ofComputing
Machinery(ACM). It is consistent withthe firstcomputer
science coursein afour-year program andshould transfer
to mostsuch programs.