190 Posted Topics
Re: You are calling drawIntersect() two times: First inside function drawTriangle(), and second time inside main() | |
Re: I need a house, new car, and a yacht too. Why do you need the code? And have you tried it yourself? | |
Re: There is at least one problem :) Some computers have softwares called antiviruses. They could stop your "unnoticed" program to run. And running a program as soon as portable storage device is plugged in, you will need "autorun.ini" file. It has special code. google it | |
Re: On line 7 you have: [CODE=cplusplus] int power (int n); // function prototype [/CODE] And later you call your function: [CODE=cplusplus] float power(float a, int n) [/CODE] | |
Re: You cannot return a pointer in one case, and "packet" in other. Both should be packets, or pointers. How do you want to use this function? | |
Re: See if you can use vector::get_allocator() I'm not sure if it would work, but try it | |
Re: I presume h is a pointer to the first node? Like: NODE* h; In that case, this code: [CODE=c] if(*h==NULL) //should be: if (h == NULL) [/CODE] Because (*h) is actualy the node itself, and not a pointer. | |
Re: It's a bad habbit to mix "cin>>" and getline(). The thing is: when you call cin>>, he gets what you need (in this example, char), but leaves everything else (including newline '\n'). And then when getline is called, it just picks up '\n' and stops. Before calling getline, add this: … | |
Re: He could always use: [CODE=cplusplus] Contestant *c = new Contestant(arg1, arg2); [/CODE] BOTTOM LINE IS: Don't allocate dynamically unless you need to. And you need to do it if you don't know (for example) number of contestors. But even then, you could make a vector<Contestant> to store all of them | |
Re: There's no point in asking "which loop do I HAVE to use." Every loop does the same thing. You can try it yourself: write something with for-loop, then try to write same thing with other two loops. | |
Re: And what have you done so far? :) It's rather interesting: n!/(x!*(n-x)!) different combinations, where n is size of string typed, and x is size of output strings | |
Re: Found this using google: [URL="http://snippets.dzone.com/posts/show/2130"]Example[/URL] [CODE] 1 2 private void ImportCountries() 3 { 4 string delimiter = ","; 5 string fileName = @"c:\countrylist3.csv"; 6 7 StreamReader sr = new StreamReader(fileName); 8 9 try 10 { 11 while (sr.Peek() >= 0) 12 { 13 string r = sr.ReadLine(); 14 string[] items … | |
Re: [QUOTE=ssharish2005;700183][code] int return1 (int n)[COLOR="Red"];[/COLOR] [/code] Why is that semicolon there??? Delete that! Syntax error ssharish[/QUOTE] And why is it called return1??? It should be fact!!! | |
Re: You need root pointer that will point at root node inside main fnc. And then call: tree.swapSubtreeNodes(root); | |
Re: Here's what you have to do: [CODE=cplusplus] # include<iostream> using namespace std; int main() { int i; cout << "Please enter the size of square: "; cin >> i; for(int col=0; col<i; col++) { cout <<endl<<endl; for(int row=0; row<i; row++) { if((col==0 || col==i-1) || (row==0) || (row ==i-1)) { … | |
Re: [CODE=c] #include <stdio.h> #include <termios.h> #include <unistd.h> int getch(){ struct termios oldt, newt; int ch; tcgetattr( STDIN_FILENO, &oldt ); newt = oldt; newt.c_lflag &= ~( ICANON | ECHO ); tcsetattr( STDIN_FILENO, TCSANOW, &newt ); ch = getchar(); tcsetattr( STDIN_FILENO, TCSANOW, &oldt ); return ch; } [/CODE] It works for me. … | |
Re: I don't know. What do you know in c? I started (and still am) as a hobbie programmer, and I learned stuff mostly on internet and e-books. I'm not a good PROGRAMMER, because to be programmer you have to really be one. But here's something for you: do you know … | |
Re: I don't see a problem. You don't need this piece of code: [CODE=cplusplus] { int old_number= 0; int current_number = 1; int next_number; } [/CODE] | |
Re: The code is horrible. You still have a lot to learn. But first: [CODE=cplusplus] float calculate_mile_per_hour(float miles, float minutes) //; there's no semicolon here!!! { float mile_per_hour; miles_per_hour = (miles * 60)/minutes); return (mile per hour); } [/CODE] | |
Re: This is actually very interesting. Well, first thing, i managed to call const constructor by doing this to main: [CODE=cplusplus] int main () { const MyClass f(4); cout << "In main before Func call: f.x = " << f.x << endl; Func (f); cout << "In main after Func call: … | |
Re: A class should contain only one complex number, not two! You didn't put default constructor in code. ... The code is full of errors | |
Re: Line 24. is wrong. It has to be inside for-loop. Look up for reading files | |
Re: Why is ADD 01011? Do you have some table or? | |
I'm a beginner in that area, but would like to learn more. Is there any nice tutorial on the web for Windows OS regarding multithreading? | |
Re: I can't tell you much without any more info. But just like this: 1. Your .h and .c file need to have the same name 2. In your main function you only include .h file 3. And you have to write: [CODE=c] #include "yourname.h" //and NOT: // #include <yourname.h> [/CODE] | |
Re: If you want to be able to write [CODE=cplusplus] something = 4 + var; [/CODE] You have to overload once more operator+. First, declare it as friend of class, and then write it like: [CODE=cplusplus] Array<T> operator+ (const float f, Array<T> myVal); [/CODE] That's because if you define operator+ as … | |
Re: You don't need to write your own list! [URL="http://www.cplusplus.com/reference/stl/list/"]Lists in c++[/URL] And "class" is reserved c++ keyword, you can't use it as varable named class! | |
Re: Can you be more specific? Why do you need string? Maybe you can use vector<char> instead of array of chars? | |
Re: Well, first, "class" is a c++ keyword, you can't use that name. Second, that last else in your code should be: else if (weight >= 3500 && year >= 1980) or: else Because else means "if nothing before is true", it can't have an expression to evaluate. | |
Re: Sounds like you're in a hurry... First of all, DON'T USE <iostream.h> and <string.h>... Instead use <iostream> and <cstring>. Second, main can't be declared like that, it has to be: int main(){ //code here return 0; } Cheers! EDIT: and yes, you are using system(), that means you have to … | |
Re: And what is the problem? To help you a little, your sequence is the same as: (-1)^2 * x^1/1! + (-1)^3 * x^2/2!... | |
Re: If print is a function... you need brackets: (currnode->contact).print(); | |
Re: You can use ostringstream from <sstream>, i use that, although it may not be the easyest way. [CODE] #include <sstream> std::string Convert (float number){ std::ostringstream buff; buff<<number; return buff.str(); } [/CODE] ostringstream and istringstream are basically the same as cout and cin, but they don't print stuff on screen. So … | |
Re: It's a long shot, but maybe while optimizing compiler got rid of unneeded functions and code in library? | |
Re: The best thing is not to use string to hold only one letter (very bad idea). So instead of [CODE]string letter;[/CODE] you better write: [CODE]char letter;[/CODE] HTH | |
Hi all. I've written my own class Complex, that stores complex numbers. I've overloaded a whole bunch of operators so that you can work with them like with normal numbers. Then i wanted to overload 'new', but I tried it before overloading, and it "seems" to be working. I can … | |
Hello. Any way of preventing multiple instances of executables? I'm writing a program that uses a file, it would be quite messy if someone would start another instance of same program. If it depends on OS, I would like to see solutions for windows and unix-type (linux) systems. Thanx |
The End.