Forum: C++ Nov 13th, 2008 |
| Replies: 9 Views: 941 What have you done so far? We don't solve homeworks |
Forum: C++ Nov 11th, 2008 |
| Replies: 2 Views: 1,366 Well, you obvioulsy need to increment counter each time you add a node, and decrement it each time you remove a node. It's really not hard, just put it in insert, delete, and create list.
For... |
Forum: C++ Oct 29th, 2008 |
| Replies: 8 Views: 615 Try to see if the problem is input or your class.
Remove all user inputs from main and put something yourself in it. If it works, problem is only in input. |
Forum: C++ Oct 24th, 2008 |
| Replies: 15 Views: 984 Ah, now you've said your problem. Solution is simple:
AND && (notice, two & signs)
OR ||
NOT ! |
Forum: C++ Oct 19th, 2008 |
| Replies: 2 Views: 307 while( chioce != 'n' );}
should actually be:
} while( chioce != 'n' );
Have a nice coding :) |
Forum: C++ Oct 19th, 2008 |
| Replies: 8 Views: 572 Remember that array is double pointer, just like ar. You cannot write ar[x], it is 2D array: ar[x][y]! |
Forum: C++ Oct 17th, 2008 |
| Replies: 2 Views: 1,243 Please mark this thread solved then |
Forum: C++ Oct 16th, 2008 |
| Replies: 9 Views: 717 THIS compiled ok on dev-cpp:
int main()
{
DWORD dwThreadId;
HANDLE myThread;
void *ptr=NULL;
myThread = CreateThread(
NULL, |
Forum: C++ Oct 15th, 2008 |
| Replies: 2 Views: 419 If you want to determine n-th digit (from the back, so second digit in 1234 is 3) in a number, you do this:
a = number%(10^n) (now your digit is in first place)
digit = a/(10^(n-1)) (now everything... |
Forum: C++ Oct 14th, 2008 |
| Replies: 5 Views: 363 You have to pass variables as an argument.
If you want to pass one argument of type char to a function that returns bool you declare function:
bool Foo(char a_char)
And you call that function... |
Forum: C++ Oct 13th, 2008 |
| Replies: 8 Views: 572 int a[m][m]
int *ptr = a;
int **ptr = ptr[m];
This doesn't make any sense. If you have to assign dynamic memory, you cannot type int a[m][m];.
Yes, you have to use pointers. Don't worry,... |
Forum: C++ Oct 12th, 2008 |
| Replies: 8 Views: 623 It shouldn't happen, but this code isn't giving anything |
Forum: C++ Oct 11th, 2008 |
| Replies: 11 Views: 1,471 Huh? ifstream function cannot give ofstream error.
Be sure that you've changed declarations in header file too!
And no, you don't need to make private variables references. Only the function... |
Forum: C++ Oct 11th, 2008 |
| Replies: 11 Views: 1,471 Like twomers said, just try to return them as references:
ifstream& FileHandler::getFileIn()const{
return fileIn;
} |
Forum: C++ Oct 11th, 2008 |
| Replies: 11 Views: 1,471 Post a small code where you are using your function, please |
Forum: C++ Oct 11th, 2008 |
| Replies: 11 Views: 1,384 Zip and post entire code, please.
It's frustrating me now too :) |
Forum: C++ Oct 11th, 2008 |
| Replies: 2 Views: 475 First: this is not C++ program!
Second: scanf_s - what kind of function is that? I don't know, maybe it exists, but I've heard only of scanf.
Third: solution is simple, remove blank space between... |
Forum: C++ Oct 11th, 2008 |
| Replies: 11 Views: 1,384 I'm not sure about this.
Function can access IT'S own members (this->memb1; this->memb2;)
But I'm really not sure about accessing other instance of same type...
Maybe your problem is in... |
Forum: C++ Oct 11th, 2008 |
| Replies: 11 Views: 1,384 (*this) is returned so you can write things like:
myObjA = myObjB = myObjC; |
Forum: C++ Oct 11th, 2008 |
| Replies: 11 Views: 1,384 Are you sure this code works:
ll = queue.ll;
'll' is under private section, right? I'm not sure if you can access it.
Here's my code example if it helps:
//operators
//=
Complex&... |
Forum: C++ Oct 11th, 2008 |
| Replies: 3 Views: 432 Some changes:
#include <iostream>
using namespace std;
const int MAX = 5, MAX2 = 3;
class notebook {
int num;
public :
notebook (); //this is wrong. Either write some... |
Forum: C++ Oct 8th, 2008 |
| Replies: 8 Views: 487 You obviously have three options about kwh, and using if-else is wrong approach.
Instead use:
if (kwh <= 20){
//do some coding here
}
else if (kwh > 20 && kwh <= 40){
//do other... |
Forum: C++ Oct 6th, 2008 |
| Replies: 2 Views: 365 I made slight adjustment:
sky.erase(sky.begin()+x);
More on: http://www.cplusplus.com/reference/string/string/erase.html
EDIT: oh yes, x <= sky.size() is wrong, should be x < sky.size() |
Forum: C++ Oct 5th, 2008 |
| Replies: 18 Views: 1,168 Simplyfied, there is some "GODlike" program that starts your C++ code:
int a = main();
//do stuff with a
If you write "void main()" variable a will be garbage.
MOST of the time, it doesn't... |
Forum: C++ Oct 5th, 2008 |
| Replies: 18 Views: 1,168 Ok, and you have just one slight error that programmers freak about. Instead of writing
void main(), consider using int main(). |
Forum: C++ Oct 5th, 2008 |
| Replies: 18 Views: 1,168 //start printing numbers
for (i = starting_num; i <= ending_num; i++){
cout<<i;
cout<<" " //this prints separation between two numbers
} |
Forum: C++ Oct 5th, 2008 |
| Replies: 18 Views: 1,168 Separate printout to the screen in:
dots before numbers and number.
So, first, if you are in row 0 (first one) the dots should be invert from that (like some_value - nr_of_row), so if you go down... |
Forum: C++ Oct 5th, 2008 |
| Replies: 18 Views: 1,168 You need two for-loops.
First one (outer) should count rows, while inner one should (depending of the row it's in) count columns |
Forum: C++ Oct 5th, 2008 |
| Replies: 4 Views: 3,736 How do you assing memory to each pointer? |
Forum: C++ Oct 5th, 2008 |
| Replies: 2 Views: 423 How's that a programming question?
Here:
1 2 3 4
. 6 7 8
. . 1 2
. . . 6
That's uper triangle |
Forum: C++ Oct 4th, 2008 |
| Replies: 7 Views: 1,269 And of course, to write 'A', 'C', 'G', not "A", "C", "G" |
Forum: C++ Oct 4th, 2008 |
| Replies: 7 Views: 1,269 What is this:
if (genArray[i] == "ACG")
genArray[i] == some_character, not some_string!
The code isn't that simple... You have to check char by char if 'A' then 'C' then 'G' occurs!
And of... |
Forum: C++ Sep 29th, 2008 |
| Replies: 19 Views: 2,046 typedef List<String^>^ Vec1;
typedef List<Vec1> Vec2;
Vec2 List1;
for( int j = 0; j < 1000; j++ )
{
Vec1 Row;
for( int i = 0; i < 1000; i++ )
{ |
Forum: C++ Sep 29th, 2008 |
| Replies: 19 Views: 2,046 Actually, that is a list, not a vector. Minor differences, but still.
Here's one way (matrix of strings):
typedef vector<string> row;
vector<row> *vec1 = new vector<row>; |
Forum: C++ Sep 28th, 2008 |
| Replies: 6 Views: 1,898 I belive it stores array of strings (all read froom same line, but separated with Delimiter), but am not sure. Try it |
Forum: C++ Sep 28th, 2008 |
| Replies: 6 Views: 1,898 Found this using google: Example (http://snippets.dzone.com/posts/show/2130)
1
2 private void ImportCountries()
3 {
4 string delimiter = ",";
5 string... |
Forum: C++ Sep 28th, 2008 |
| Replies: 5 Views: 1,382 Here's what you have to do:
# include<iostream>
using namespace std;
int main()
{
int i; |
Forum: C++ Sep 27th, 2008 |
| Replies: 11 Views: 1,175 I don't see why there should be any difference. When you write:
void MyClass Func (const MyClass f)
//or even simply:
const MyClass f(some_MyClass_obj);
And let's say we call Func:
... |
Forum: C++ Sep 27th, 2008 |
| Replies: 11 Views: 1,175 Ok, I have an idea, but am not sure 100%.
When you write:
void Func (const MyClass g)
You say to compiler: MyClass g (I changed a name from f, but it's irrelevant) will not change!
But, that... |
Forum: C++ Sep 27th, 2008 |
| Replies: 11 Views: 1,175 This is actually very interesting. Well, first thing, i managed to call const constructor by doing this to main:
int main ()
{
const MyClass f(4);
cout << "In main before Func call: f.x... |