Search Results

Showing results 1 to 40 of 41
Search took 0.01 seconds.
Search: Posts Made By: Sci@phy ; Forum: C++ and child forums
Forum: C++ Nov 13th, 2008
Replies: 9
Views: 941
Posted By Sci@phy
What have you done so far? We don't solve homeworks
Forum: C++ Nov 11th, 2008
Replies: 2
Views: 1,366
Posted By Sci@phy
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
Posted By Sci@phy
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
Solved: And or not
Views: 984
Posted By Sci@phy
Ah, now you've said your problem. Solution is simple:
AND && (notice, two & signs)
OR ||
NOT !
Forum: C++ Oct 19th, 2008
Replies: 2
Solved: Syntax Error
Views: 307
Posted By Sci@phy
while( chioce != 'n' );}
should actually be:
} while( chioce != 'n' );

Have a nice coding :)
Forum: C++ Oct 19th, 2008
Replies: 8
Views: 572
Posted By Sci@phy
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
Posted By Sci@phy
Please mark this thread solved then
Forum: C++ Oct 16th, 2008
Replies: 9
Views: 717
Posted By Sci@phy
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
Posted By Sci@phy
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
Solved: C++...
Views: 363
Posted By Sci@phy
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
Posted By Sci@phy
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
Posted By Sci@phy
It shouldn't happen, but this code isn't giving anything
Forum: C++ Oct 11th, 2008
Replies: 11
Views: 1,471
Posted By Sci@phy
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
Posted By Sci@phy
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
Posted By Sci@phy
Post a small code where you are using your function, please
Forum: C++ Oct 11th, 2008
Replies: 11
Views: 1,384
Posted By Sci@phy
Zip and post entire code, please.
It's frustrating me now too :)
Forum: C++ Oct 11th, 2008
Replies: 2
Solved: Scanf problem
Views: 475
Posted By Sci@phy
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
Posted By Sci@phy
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
Posted By Sci@phy
(*this) is returned so you can write things like:
myObjA = myObjB = myObjC;
Forum: C++ Oct 11th, 2008
Replies: 11
Views: 1,384
Posted By Sci@phy
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
Posted By Sci@phy
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
Posted By Sci@phy
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
Posted By Sci@phy
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
Posted By Sci@phy
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
Posted By Sci@phy
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
Posted By Sci@phy
//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
Posted By Sci@phy
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
Posted By Sci@phy
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
Solved: vector <char*>
Views: 3,736
Posted By Sci@phy
How do you assing memory to each pointer?
Forum: C++ Oct 5th, 2008
Replies: 2
Solved: Matrix
Views: 423
Posted By Sci@phy
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
Posted By Sci@phy
And of course, to write 'A', 'C', 'G', not "A", "C", "G"
Forum: C++ Oct 4th, 2008
Replies: 7
Views: 1,269
Posted By Sci@phy
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
Posted By Sci@phy
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
Posted By Sci@phy
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
Solved: StreamReader
Views: 1,898
Posted By Sci@phy
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
Solved: StreamReader
Views: 1,898
Posted By Sci@phy
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
Posted By Sci@phy
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
Posted By Sci@phy
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
Posted By Sci@phy
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
Posted By Sci@phy
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...
Showing results 1 to 40 of 41

 


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

©2003 - 2009 DaniWeb® LLC