Cpp_notes_summary_5

Cpp_notes_summary_5 - Chapter 5 Object Oriented Programming...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 5 Object Oriented Programming 5.1 structs We use structs to group connected variables. structs // Define a s t r u c t struct struct name { data type member variable1 , member variable2 ; data type member variable3 , member variable4 ; } ; // Declare s t r u c t v a r i a b l e s struct name variable1 , variable2 , . . . ; //Use . to work with member v a r i a b l e s for example variable1 . membervariable1 =1.2 5.1.1 Passing Structs to Functions The frst problem is that in order to have a Function that has vector arguments or returns a vector we need to some how have the defnition oF vector available to both the Function and the main Function. How can we do that? Put it in a header fle and include it in both fles. vector Functions.h struct Vector { double x , y , z ; } ; Vector cross product ( Vector A, Vector B) ; void cross product ( Vector A, Vector B, Vector& cross ) ; vector Functions.cpp #include ” vector Functions . h” void cross
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

Cpp_notes_summary_5 - Chapter 5 Object Oriented Programming...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online