Search Results

Showing results 1 to 40 of 55
Search took 0.01 seconds.
Search: Posts Made By: BeyondTheEye
Forum: C++ 12 Days Ago
Replies: 1
Views: 182
Posted By BeyondTheEye
Assignment:
Write a function zet_om_naar_getal(getal) that calculates the binary representation from a decimal number as a string, using recursion.

What I have so far:
string...
Forum: C++ 14 Days Ago
Replies: 2
Views: 215
Posted By BeyondTheEye
From what I can see the error is in your stack/queue declaration. You're adding charachters, not strings.queue<char> aQueue;
stack<char> aStack;

//instead of

queue <string> aQueue;
stack...
Forum: C++ 17 Days Ago
Replies: 7
Views: 319
Posted By BeyondTheEye
FirstPerson's code works, but it's bad coding practice to hard code the ASCII numbers. Also stated in your assignment, if you are to use character literals you just have to change the numbers to...
Forum: C++ 19 Days Ago
Replies: 2
Views: 171
Posted By BeyondTheEye
bool quit = false;
while(!quit) //And some other conditions, obviously
{
//Do something
if(break)
quit = true; //Break out of the loop by failing the condition for the loop,...
Forum: C++ 22 Days Ago
Replies: 17
Views: 433
Posted By BeyondTheEye
You missed the point in references. When a variable is passed to a function, a copy is made, so you can't change the original. When a pointer, or an array, is passed you CAN change the value, it just...
Forum: C++ 22 Days Ago
Replies: 9
Views: 208
Posted By BeyondTheEye
From what I can tell from the error your account class has no default constructor. When you declare a constructor for a class, the compiler expects you to supply all constructors, including the...
Forum: C++ 22 Days Ago
Replies: 34
Views: 1,139
Posted By BeyondTheEye
Change line 55 from cin >> newTeam, sizeof(newTeam), stdin; to cin >> newteam;
Line 74 still has the same problem. You fixed your cout statement on the line above, but not the cin line. I'd follow...
Forum: C++ 22 Days Ago
Replies: 2
Views: 298
Posted By BeyondTheEye
I guess you're not familiar with this forum, so I'll just refer you here (http://www.daniweb.com/forums/announcement8-2.html).
Forum: C++ 23 Days Ago
Replies: 8
Views: 209
Posted By BeyondTheEye
Use substr from the string library. If you want it as an int you can use atoi from there.
string number = S.substr(stringIndx); //Copies from stringIndx to end into number
int num =...
Forum: C++ 24 Days Ago
Replies: 4
Views: 217
Posted By BeyondTheEye
An ofstream is an object, not a function.
To open a file using ofstreams you first create the object, then open the file. Like so:
ofstream file;
file.open("a.txt");
//Do something
file.close();...
Forum: C++ 25 Days Ago
Replies: 1
Views: 217
Posted By BeyondTheEye
Function calls always require paranthesies(), even if there are no parameters.
In your case you'd have to do something like:
int celcius, farenheit;
cel_to_far(celcius, farenheit);
cout << "When...
Forum: C++ Oct 18th, 2009
Replies: 6
Views: 259
Posted By BeyondTheEye
You should either include "hashTable.cpp", or have the class declaration and implementation in the same file(as firstPerson already pointed out)
Forum: C++ Oct 18th, 2009
Replies: 5
Views: 331
Posted By BeyondTheEye
Havn't tested this, so there might be a few errors:

void split_string(const string& src, vector<string>& dst, char split)
{
int startPos = 0, endPos = src.find(split);
while(endPos !=...
Forum: C++ Oct 14th, 2009
Replies: 4
Views: 273
Posted By BeyondTheEye
You might want to change your destructor.

delete [] st;

instead of


delete st;
Forum: C++ Oct 11th, 2009
Replies: 8
Views: 318
Posted By BeyondTheEye
I'd switch the order of printing around. First print a comma, then print the number.
This does require you to find the first number beforehand, though.

void set::Display() const
{
cout <<...
Forum: C++ Oct 3rd, 2009
Replies: 10
Views: 274
Posted By BeyondTheEye
Figured it out. It appears new Type isn't quite the same as new Type[1]
Forum: C++ Oct 3rd, 2009
Replies: 10
Views: 274
Posted By BeyondTheEye
Same problem as in the first post, without a dynamic array. I've never had it with any other class, so I'd assume Category is the problem, not the Array class.
Forum: C++ Oct 3rd, 2009
Replies: 10
Views: 274
Posted By BeyondTheEye
Thanks for the info. I'll go and change that..

EDIT:
Seems to still give crashes. If I use delete [] mainArray on my Category class it still crashes
Forum: C++ Oct 3rd, 2009
Replies: 10
Views: 274
Posted By BeyondTheEye
#define DEFAULTSIZE 0

template <class T>
class Array
{
public:
//Public constructor
Array() {itsSize = DEFAULTSIZE; itsElements = 0;}
//Copy constructor
...
Forum: C++ Oct 3rd, 2009
Replies: 10
Views: 274
Posted By BeyondTheEye
I would normally go with option (3). However, I was using the class in a program with a self-written form of Vector, and it kept crashing upon destruction of the object.
I was hoping there was a way...
Forum: C++ Oct 3rd, 2009
Replies: 10
Views: 274
Posted By BeyondTheEye
I've created a class, Category.
#ifndef CATEGORY_H_INCLUDED
#define CATEGORY_H_INCLUDED

#include <string>
using std::string;

enum Type {Integer, Double, Bool, String, Date, Time};

class...
Forum: C++ Oct 1st, 2009
Replies: 9
Views: 328
Posted By BeyondTheEye
No good.. The Pony::operator= will never be called using a Horse pointer. Even if the Pony object is assigned a color value.
Forum: C++ Sep 30th, 2009
Replies: 9
Views: 328
Posted By BeyondTheEye
Normally, yes. But suppose the following code:
//Horse.h
#ifndef HORSE_H_INCLUDED
#define HORSE_H_INCLUDED

class Horse
{
public:
Horse(int age) : itsAge(age) {}
Forum: C++ Sep 29th, 2009
Replies: 9
Views: 328
Posted By BeyondTheEye
Is there no other way than having several functions like:

virtual void BaseClass::operator=(class1&);
virtual void BaseClass::operator=(class2&);
// ...

It would make sense to declare the...
Forum: C++ Sep 29th, 2009
Replies: 9
Views: 328
Posted By BeyondTheEye
That would work in this case.
But the application I'm making has more complicated classes. These classes have different member variables than the base class, so it's impossible to change them using...
Forum: C++ Sep 28th, 2009
Replies: 9
Views: 328
Posted By BeyondTheEye
I'm having trouble getting the right operator to be accessed using polymorphism.
The code below is a simple representation of the problem, but it should get the point across.

//Horse.h

#ifndef...
Forum: C++ Dec 19th, 2008
Replies: 8
Views: 568
Posted By BeyondTheEye
class complex
{
friend ostream& operator<<(ostream& output, const complex& V);

private:
double REAL;
double IMG;

public:
complex();
Forum: C++ Dec 16th, 2008
Replies: 6
Views: 577
Posted By BeyondTheEye
I'm guessing you're looking for something like this. You have a class School, each School having a specified amount of Student's.

class School
{
private:
String schoolName;
vector<Student>...
Forum: C++ Dec 14th, 2008
Replies: 7
Views: 809
Posted By BeyondTheEye
Sorry, I didn't test it before. This does work:


#include <iostream>
#include <string>

using namespace std;

int main(int argc, char *argv[])
{
Forum: C++ Dec 14th, 2008
Replies: 7
Views: 809
Posted By BeyondTheEye
Version with loop:


bool Error = true;
while(Error)
{
{
string n;
string s;
Forum: C++ Dec 13th, 2008
Replies: 7
Views: 809
Posted By BeyondTheEye
I'm supposing you're obtaining user input by using:
cin >> name;

If you are, I suggest you read this thread (http://www.daniweb.com/forums/thread90228.html). The problem with cin is it only takes...
Forum: C++ Dec 13th, 2008
Replies: 11
Views: 599
Posted By BeyondTheEye
if( s=="m" || "male")
Should be
if( s=="m" || s=="male")

You have to compare it to the s variable again, else it will evalute "male" as a char array, which will always return true.
Forum: C++ Nov 28th, 2008
Replies: 10
Views: 722
Posted By BeyondTheEye
An example:

#include <iostream>

std::ifstream openFile("filename.txt");
std::cout << "::::::::::::::::::::::::::::FILECONTENTS::::::::::::::::::::::::::::" << std::endl;
char getFile;
while...
Forum: C++ Nov 28th, 2008
Replies: 10
Views: 722
Posted By BeyondTheEye
There's nothing wrong with the program. You're succesfully opening it.
To have the effect you want, you first need to get the data from the file then write it back to the screen.
Forum: C++ Nov 26th, 2008
Replies: 3
Views: 297
Posted By BeyondTheEye
There's plenty of programs out there which record keyboard input and mail it through. I'm supposing you could use one of those.
Note, I wouldn't trust all of those to be safe...
Forum: C++ Nov 23rd, 2008
Replies: 11
Views: 652
Posted By BeyondTheEye
cin >> interest;
totaldep += deposited;
totalwith += withdrawn;
interest = interestRate * deposited;
deposited += interest;

You're asking the user to input a variable named...
Forum: C++ Nov 23rd, 2008
Replies: 11
Views: 652
Posted By BeyondTheEye
Suppose the annual interest rate is 10%. It means you'll get 10% of whatever amount is stored on an annual basis.
Be it the case you have 100$ deposited for a whole year at 10% interest rate.
...
Forum: C++ Nov 22nd, 2008
Replies: 12
Views: 1,311
Posted By BeyondTheEye
sqrt(-1) = 1 * i
Where i can't be defined. You can't calculate it.

So if you were to return it as a result, it'd have to be a string like this:
"<Real part> + <Imaginary part> * i", in this case...
Forum: C++ Nov 13th, 2008
Replies: 17
Views: 998
Posted By BeyondTheEye
Sounds like you want something like this...
Note that this code won't compile. It was just an example, with it still being your work to implement it.

class Ship
{
std::String GetType() {return...
Forum: C++ Sep 18th, 2008
Replies: 7
Views: 1,935
Posted By BeyondTheEye
Include the System:: Drawing(Remove the space) namespace at the start of your file, or write it like this: System:: Drawing::Font^(Once again, remove the space)
Showing results 1 to 40 of 55

 


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

©2003 - 2009 DaniWeb® LLC