49,757 Topics
| |
/*The Fraction + and Fraction / are not being allowed to access private members declared in class Fraction. Any suggestions? */ [CODE]class Fraction { public: Fraction(); Fraction(int, int); void setNum(int); void setDen(int); int getNum(){return num;} int getDen(){return den;} void reduce(); void print(){cout << num <<"/"<< den;} friend ostream& operator << … | |
Is there any way to reduce the number of times you have to write: template<typename T> for a bunch of functions all using the same template parameters? i.e., something like this: template<typename T> namespace my_functions_using_T { T function_do_something(const T & t); void function_do_something_else(T & t); } (besides making them all … | |
Hi, i really don't know what to do guys can you help me with this code for my matrix program? this program is not yet finished and i am stuck with this problem [CODE]#include <iostream> #include <math.h> using namespace std; int main() { int rotx, roty, rotz, n, ac1, ac2, … | |
Ok, I've been working on this for about 4 hours, but I cannot get it to work! I'm starting with a char, then I need it to become a const char so I can use strcmp in my if statements. If there's anything wrong in that idea, please tell me … | |
since few minutes I tried practice "using FOR loop with IF statement" to test user "Even Numbers"(divided / 2) in console screen, I wrote this trivial program to print the statement "IS even number" if the number divided by 2, and print "NOT even number" when not divided by 2, … | |
What is this->Controls->Add(color);? What will happen if code below is without this->Controls->Add(color);? What is the result from the code this->Controls->Add(color);? color=new Button(); color->Text="Ok"; color->Top=320; color->Left=420; this->Controls->Add(color); | |
I hear that to create a custom icon for your exe file, and must create a .ico icon, then link it to a resource file, which is linked to the main .exe file. I'm not sure how to do this though. I have my icon I want to use for … | |
I'm writing a simple program that reads a text file and counts the vowels in it and outputs how many are included. With the code I have I keep getting the wrong number of vowels outputted. Can anyone see where I made a mistake, I can't figure it out. my … | |
Arrival.o: In function `NodeItem': /home/jonyb/Desktop/A3-Q2/NodeItem.h:5: undefined reference to `vtable for NodeItem' Arrival.o: In function `~Event': /home/jonyb/Desktop/A3-Q2/Event.h:8: undefined reference to `NodeItem::~NodeItem()' Event.o:(.rodata._ZTI5Event[typeinfo for Event]+0x8): undefined reference to `typeinfo for NodeItem' These 3 errors repeat themselves for all my files accessing NodeItem.h and NodeItem.cpp Now I've looked around and all I could … | |
The function, std::vector.push_back takes a paramater of the type: [const t &]. with t being the type that the vector was constructed with. What I need to do is convert [*this] to a [const t &]. Is there any way that I can do this? This is the code that … | |
I am trying to get 'SERVERPROPERTY ('edition') using ADODB. I have a connection to a database but I keep getting Error 80040e14 and unexpected token SERVERPROPERTY was found following BEGIN-OF-STATEMENT. Any ideas how to fix this. Thanks Joey | |
Question by ~s.o.s~ Write a program which will perform the job of moving the file from one location to another. The source and destination path will be entered by the user. Perform the required error checking and handle the exceptions accordingly. (Intermediate) [code=c++]#include<fstream> #include<iostream> #include<cstdio> using namespace std; int main(){ … | |
So, I'm trying to create a Caesar Cipher using C++. It's supposed to be able to calculate the shift depending on what letter appears the most (which would mean that it's "e"). It's also supposed to have wrap around text, which I've tried to think of a way to have … | |
Good evening Daniweb, I have another idiotic problem which comes from making an arrival subclass out of Event. I have a few other subclasses of Event and they aren't giving me any trouble. I have tried to copy/paste/rewrite to eliminate any stupid typos. Arrival.h:7: error: expected class-name before ‘{’ token … | |
Hi, I've got a problem with a program that boils down to strange behavior by the vector container class. It seems to not want to call constructors enough but calls destructors too many times: [CODE] #include <vector> #include <iostream> using std::cout; int constructor_count=1,destructor_count=1; class obj{public: obj(){ cout<<"C: "<<constructor_count++<<'\n'; } ~obj(){ … | |
What is the best way to add something to the nested vector of a multidimensional vector...I already have ints inside, lets say VECNAME[rowone][columntwo]...How can I add to columntwo??? | |
Hi I am supposed to write that implements a simple version of the BucketSort algorithm the only problem is I have no clue what that is. Any tips and examples on this would be awesome Thanks | |
Hello, I am runing this program this works if I dont delete anything in destructor. If I use delete variable name in destructor then it creates problem. It creates problem when destrctor get called while operator ovrerloading. I think It is trying to delete the memory that has already been … | |
| |
Hello Folks: I had previously posted this problem and someone on this forum suggested that i used s[i] == 'a' || s[i] == 'A' .... but what I have here completely makes sense.. Can you please take a look at it ? [CODE] #include<iostream> #include<string> using namespace std; int main() … | |
My program keeps crashing and I can't see why, if I remove the line [code=php] myfile << data_[i+ndim_*j] << " "; [/code] then it runs OK...but can't see anything wrong with this line? [code=php] void Matrix::WriteToFile(std::string fname) const { ofstream myfile; myfile.open ( (fname+".txt").c_str() ); for (int i = 0; … | |
My function is: [code=php] void Matrix::WriteToFile(std::string fname) const { ofstream myfile; myfile.open ("std::string fname.txt"); for (int i = 0; i<data_.size(); i++) myfile << data_[i] << " "; myfile.close(); } [/code] and then in the main I have A.WriteToFile("hello"), but it's saving it as fname still? Can anyone please tell me … | |
Write a program that will read in 10 test scores. Print out all 10 scores, then print the highest score, and then the lowest score. Ok i got this so far but i do not know how to print the highest or lowest. [code] #include<iostream> using namespace std; int main() … | |
I wish there was an option in the "What are you posting" for tutorials hehe. But I guess I will just have to right it here :). If anyone else has any pointers (pun intended) let me know ;). Ok if your like me and were wondering how to accept … | |
| |
Hey guys, I'm new to this whole programming deal and have browsed around these forums here or there to learn a few things. My latest assignment is to create a working tic tac toe game, including functions to initialize the game board, print the board, check the game status, checking … | |
Good afternoon Daniweb, I have a simple (and probably idiotic) problem today, I have a simplistic program that simulates a Train station, trains come in, they go into a stationDock and come out after a while. The stationDocks are an array of trains, either pointing to a train or being … | |
hello all; i'm having a problem with my output. the program that i'm writing is supposed to take a number input than display the output as asterisks. so if the input is 4 the output should be: * ** *** **** however, i'm just getting a single column of asterisks. … | |
Guys..Can anyone help me to explain what really happened in the while loop and both of the if else loop that makes this coding can find the root using bisection method.Thank you...[code]#include "stdafx.h" #include <iostream> #include <cmath> #include <iomanip> using namespace std; double f( double); int main ( int argc, … | |
I was wondering if there were away to repeat the same test multiple times and average the time. The code works fine [CODE] #include <cstdlib> #include <ctime> #include <iostream> using namespace std; void PrintArray(int* array, int n); void QuickSort(int* array, int start, int end); int partition(int* array, int pivot, int … |
The End.