General C++ Programming - March 2009 (Page 18)

by dirbax
C++ to Mathematics
 
Hi , is it possible to transform the following code to math int F( int n ) { int r=0; int mid=n/2; for( int i=0 ; i<n ; i++) { if( i<mid) r+=1 ; if( i...
[6 replies] Last: What about this function int F( int n , int a, int b ) { int r... (by dirbax)
by tition
Why return object& when overloading operator=?
 
Hi all, Why do most c++ tutorials on overloading operator= suggest that the operator= return object& ? In code form: Why class object { public: ...
[3 replies] Last: Thanks to both, all understood! I wouldn't want anyone who uses exp... (by tition)
Derived Vector Class
 
My class is causing an error explosion... Hundreds of errors from: .../bits/vector.tcc What is wrong with it? I am probably not understanding how " : " ...
[6 replies] Last: I notice that you have min and max functions. You don't need them. R... (by jsmith)
by wanky
need to make timer.
 
i created a casino program with seven games in it. my professor told me that it was a simple program and asked me to insert a timer in it. she asked me to limi...
[1 reply] : Try to see if you can find useful functions in <ctime> header http://... (by Bazzy)
fatal error using .close()
 
Hey there. I'm having trouble closing a file of all things. I'm using fstream and .close() to do it. I'm only reading part way into the file, hen I save my p...
[4 replies] Last: Hi, You should also share the file you are trying to read from. I th... (by mm148881)
How Can I Insert Zeros in the Middle of a String of IP? C/C++
 
I wrote a piece of code that does the following: 1. Get IP from user in this format xx.xx.xx.xx 2. Fill zeros at the left of each segment if user did not en...
[7 replies] Last: seymore15074 (354): Best answer A+... Thanks to all who helped! ... (by f ben isaac)
hey i need to find out how to do this..
 
stopping a program when the number entered is zero my main says: cout << "Enter a number to test for primality, or zero to exit ->: "; soo im not su...
[2 replies] Last: @bufbill: your if statements are assignments not comparisons. (by jsmith)
C++ Printing
 
__ opens a dialog box that allows users to select printers other than the default printer. A. PrintController B. PrintDialog C. PrintDocument D. PrintPrev...
[1 reply] : This goes in the Windows forum. (by helios)
Favorite (or anti-) Error Messages
 
Are there error messages you love (or loathe) to see? One of mine is "long long long is too long for gcc"
[4 replies] Last: I believe MacOS calls refers to segmentation faults as "bus errors", j... (by helios)
cout did not appear and Nesting IF ELSE
 
Hi, while doing my assignment im somehow stucked somewhere which i didnt know why and i need some help. i have jus started learning abt c++. so im jus using so...
[4 replies] Last: seymore15074 posted the actual answer just before I posed my comment... (by guestgulkan)
by anan
Linked list and polynomials
 
hi there how can i access different data type in a linked list?(say p has int char,double etc) how can i add two polynomial using linked list(how do i keep tr...
[1 reply] : Consider this code structure struct node { int i; char c; ... (by kevinchkin)
decompression
 
I have stored some data in a file.txt which is hello ho3w2 are you. How can I open this file in c compiler and save the data into a new file (file2.txt) as hel...
[1 reply] : Refer to your same post in beginners section. (by kevinchkin)
File Metadata
 
Hi Guys, I was wondering if somehow we can get file's "Where from" info. I am using stat() to get other file info like creation date, modification time etc. ...
[2 replies] Last: It's HFS+ (by kevinchkin)
Function overloading
 
Hi, I've been working with a tree-like structure and encountered the following issue that I'll try to formulate in a simplified setting. Consider the following ...
[7 replies] Last: Why can't you turn the problem around? class A { public: voi... (by jsmith)
Overloading operator+
 
I cant put operator+ in the class so I'm lost. Rational operator+( const Rational& A, const Rational B ) { int Num; int Den; Num ...
[2 replies] Last: Line 9 -- remove the C. return Rational( Num, Den ); You... (by jsmith)
Problems with Compiling?
 
Hi all, I am having problems trying to compile 2 files, a.cpp and test.cpp. So my problem is that when compiling a.cpp, it states that the P class in test.cp...
[17 replies] Last: Yeah, i know my lecturer is crap. I told him it doesn't make sense too... (by shaoen01)
Exception catching not displayed?
 
Hi all, I have 2 methods with one method 1 throwing exception and method 2 that is catching the exception thrown by method 1. So my exception types are 2 emp...
[4 replies] Last: Thanks, i think it works now! (by shaoen01)
by jrohde
Overloading operator+ with two arguments
 
Hello all, Is it possible to overload the "+" operator in the following way? (This is just a short example of what I'm getting at): class MyClass { ...
[4 replies] Last: Thanks guys - makes sense. Yeah, I realize the + operator was illogic... (by jrohde)
malloc pointers created and returned within the same function
 
I'm trying to locate suspected memory leaks in someone else's code. I don't have access to the original coder, unfortunately. One thing I noticed in a couple ...
[3 replies] Last: Good point. Run Valgrind on it... (by seymore15074)
Sparse Matrix Implementation
 
The following is my implementation of a sparse matrix class. Feel free to comment on my bad coding style as well as use the code. The input file is the bcsstk14...
[8 replies] Last: I was hoping for something a bit more specific (yes indeed that was a ... (by turbozedd)
March 2009 Pages: 1... 161718192021
  Archived months: [feb2009] [apr2009]

This is an archived page. To post a new message, go to the current page.