Click here to Skip to main content
15,891,431 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Sorting a vector of a user defined type Pin
Zac Howland12-Sep-06 6:29
Zac Howland12-Sep-06 6:29 
GeneralRe: Sorting a vector of a user defined type Pin
avimitrani12-Sep-06 7:10
avimitrani12-Sep-06 7:10 
GeneralRe: Sorting a vector of a user defined type Pin
Zac Howland12-Sep-06 8:11
Zac Howland12-Sep-06 8:11 
AnswerRe: Sorting a vector of a user defined type [modified] Pin
Zac Howland12-Sep-06 4:30
Zac Howland12-Sep-06 4:30 
GeneralRe: Sorting a vector of a user defined type Pin
avimitrani12-Sep-06 5:14
avimitrani12-Sep-06 5:14 
GeneralRe: Sorting a vector of a user defined type Pin
Chris Losinger12-Sep-06 5:16
professionalChris Losinger12-Sep-06 5:16 
GeneralRe: Sorting a vector of a user defined type Pin
avimitrani12-Sep-06 5:42
avimitrani12-Sep-06 5:42 
GeneralRe: Sorting a vector of a user defined type Pin
Zac Howland12-Sep-06 5:40
Zac Howland12-Sep-06 5:40 
In C++, class and struct are pretty much the same keyword (class defaults to private protection, while struct defaults to public -- that is pretty much the only major difference).

Thus, you can create constructors for structs just as you would a class. The code below creates a default constructor and initializes each variable to a value (in this case, all 0's).

avimitrani wrote:
item_calculation() : item_num(0), weight(0.0), contribution(0.0), prediction(0.0)
{}


It is almost the same as writing it this way:

item_calculation()
{
	item_num = 0;
	weight = 0.0;
	contribution = 0.0;
	prediction = 0.0;
}


except that the first case is more efficient because the members are created and initialzed at the same time.


If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week

Zac

GeneralRe: Sorting a vector of a user defined type Pin
avimitrani12-Sep-06 5:49
avimitrani12-Sep-06 5:49 
GeneralRe: Sorting a vector of a user defined type Pin
Zac Howland12-Sep-06 6:17
Zac Howland12-Sep-06 6:17 
QuestionConvert from CStringW to CString Pin
zizzzz12-Sep-06 4:05
zizzzz12-Sep-06 4:05 
AnswerRe: Convert from CStringW to CString Pin
Rob Caldecott12-Sep-06 4:31
Rob Caldecott12-Sep-06 4:31 
GeneralRe: Convert from CStringW to CString Pin
zizzzz12-Sep-06 4:53
zizzzz12-Sep-06 4:53 
GeneralRe: Convert from CStringW to CString Pin
Rob Caldecott12-Sep-06 4:58
Rob Caldecott12-Sep-06 4:58 
AnswerRe: Convert from CStringW to CString Pin
Rinu_Raj12-Sep-06 4:35
Rinu_Raj12-Sep-06 4:35 
GeneralRe: Convert from CStringW to CString Pin
zizzzz12-Sep-06 5:21
zizzzz12-Sep-06 5:21 
GeneralRe: Convert from CStringW to CString Pin
David Crow12-Sep-06 7:15
David Crow12-Sep-06 7:15 
AnswerRe: Convert from CStringW to CString Pin
wiemounir12-Sep-06 5:17
wiemounir12-Sep-06 5:17 
GeneralRe: Convert from CStringW to CString Pin
Hamid_RT13-Sep-06 8:11
Hamid_RT13-Sep-06 8:11 
GeneralRe: Convert from CStringW to CString Pin
wiemounir13-Sep-06 23:06
wiemounir13-Sep-06 23:06 
GeneralRe: Convert from CStringW to CString Pin
Hamid_RT13-Sep-06 23:33
Hamid_RT13-Sep-06 23:33 
QuestionBinary was not built with debug information Pin
RugbyLeague12-Sep-06 3:44
RugbyLeague12-Sep-06 3:44 
AnswerRe: Binary was not built with debug information Pin
toxcct12-Sep-06 3:46
toxcct12-Sep-06 3:46 
GeneralRe: Binary was not built with debug information Pin
RugbyLeague12-Sep-06 3:50
RugbyLeague12-Sep-06 3:50 
Questionhelp please!!!!!!!!!!!!!!! Pin
wiemounir12-Sep-06 3:42
wiemounir12-Sep-06 3:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.