General C++ Programming - March 2013 (Page 16)

by EeAA
Bubble Sort Optimized
 
I'd like to optimize the bubble sort algorithm. For some reason my algorithm below has worst performance than the original bubble sort. Any ideas what I did wro...
[1 reply] : After each inner loop remember 'j' of your last swapped element and us... (by tcs)
Yet another heap corruption
 
Hello, I am having a problem with my program. Album::Album(char *_name, Song *_songs, int _songNumber, int _salesCount, int _year) { name = new...
[7 replies] Last: Oh, yes... thank you :) (by DonMito)
Comparison question
 
My question is whether anyone can help me with an idea of how to do a comparison. My objective is to remove the switch case having select a category of study...
[3 replies] Last: Thanks anir, I did use the if else for the comparison part i wanted to... (by Joshutsu)
Object that is passed to function is changed, although no pointer is passed
 
Hey there, I am posting this simplified piece of code that is a bit confusing for me. There are two functions that I call. One shows the expected results but...
[3 replies] Last: Thanks for the quick response! Now that you mention it, it really make... (by donelron)
by aj3423
template class with default value
 
Hi, Please refer to the code below, the attribute class is created with the value type and default value, but why it doesn't work for std::string? Thanks....
[9 replies] Last: Ah, I thought you were referring to the C++11 version; my mistake. (by LB)
CodeBlocks Help
 
I got codeblocks w/ mingw and installed it fine. but then, my flash drive i had it on broke and i got it on a new one. Now it cant find my compiler. i tried to ...
[1 reply] : Never Mind Fixed It (by James Parsons)
Codebank: Finding nth prime
 
Not the fastest but an elegant code written by me. // This code was written by Mert Ener #include <time.h> #include <iostream> // Requires a run button on Wi...
[14 replies] Last: > I didn't know about that "Sieve of Eratosthenes" therorem. The theo... (by JLBorges)
by kgor93
How do I loop through a vector of class objects?
 
For a beginners C++ lab, I have a base class Employee and two derived classes HourlyEmployee and SalaryEmployee. In main, I have a vector defined as vector <Emp...
[4 replies] Last: line 43 of your code: change Ve .printPay() to Ve ->printPay() THANK... (by kgor93)
by coder1
2D array sorting
 
Hi,I know how to sort a 1D array using function sort(). but if i have a 2D array how do i sort only 1 row of it (or column)? Thank you very much and i...
[2 replies] Last: @Cubbi : Thank you very much . (by coder1)
How will execute this program?
 
#include<iostream.h> #include<conio.h> void main() { int x ={1,2,3,4,5}, y ={5,4,3,2,1}, result ={0,0,0,0,0}; int i=0; while(i++<5) result =x -y ; clrsc...
[3 replies] Last: The problem is in the statement while(i++<5) This reads the value ... (by MikeyBoy)
4x for loop, 2x2D array = Confusion
 
Hi guys, As the title suggest, I have a bit of an issue. I want to move a 2d array inside another 2d array and so far i have the following: #include...
[12 replies] Last: Thanks Vlad, I will give this a shot tonight after work, see what I c... (by toomanystars)
Help me on my assignment
 
I have this question for my assignment and i don't have any idea how to do Question 1 "Allow the user to enter an integer, between 1 to 9 only. You may use th...
[3 replies] Last: TQ For the reply...And sry for the late reply =/ I did try your code ... (by xtyphoon)
simple question in strings
 
can anyone Help here ? # include <iostream> # include <algorithm> # include <string> using namespace std; struct name { string sentence ; // initialized s...
[4 replies] Last: yes, i see. you use sentence as a string but in your name struct i... (by coder777)
time-in time out function
 
Please help me to make a time-in time-out fuction which extracts the no. of hours and minutes from a string entered by the user. #include <iostream> #i...
[3 replies] Last: https://www.facebook.com/photo.php?fbid=647045105310759&set=np.1199926... (by m1rv9n41v5)
lambda expression error: expression must be a modifiable lvalue
 
Ok, the codes are: vector<vector<double>> imageFiltered; // some processing codes here parallel_for( blocked_range<unsigned>(0, imageFiltered.size()),...
[3 replies] Last: So I read the lambda expression syntax, and change the [=] to [&], now... (by Adrian Yu)
Reply soon please: Friend Function, Basic Question.
 
Can we do void setX(int value){ x = value;//Will it generate an error? If yes then why? } when class a{ int x; public: friend void setX(int); ...
[2 replies] Last: Yes, the compiler will issue an error because 'x' is non-static data m... (by vlad from moscow)
oop's
 
error occur undefined symbol "throw"
[1 reply] : You should show the full error mesage and the corresponding code. Mayb... (by vlad from moscow)
by Nanite
Printing data as it is stored in memory (binary)?
 
Before you yell at me to use the search bar you need to know that I did but didn't find anything that actually works (either that or the answers were too obviou...
[10 replies] Last: @L B Yes, yes I do. In fact I have no problem converting from base to ... (by Nanite)
by Phiru
memory leak occurs?
 
I just want to know what will happen if memory leak occurs??
[3 replies] Last: Os is a very interesting subject, explore it. (by SirSmilesaLot)
by game
Forward declaration error
 
Dear Users,, I am using OpenCASCADE environment to read STL file! Well the problem with c++ knowledge!! I face a problem, with forward declaration error w...
[2 replies] Last: Thank you very much Mikeyboy, Thank you very much for nice and clear... (by game)
March 2013 Pages: 1... 1415161718... 51
  Archived months: [feb2013] [apr2013]

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