seminar_01
This commit is contained in:
		
							parent
							
								
									2369f801af
								
							
						
					
					
						commit
						46d1c64684
					
				
					 21 changed files with 415 additions and 0 deletions
				
			
		
							
								
								
									
										20
									
								
								seminar01_overload/homework/code/05_add_price/add_price.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								seminar01_overload/homework/code/05_add_price/add_price.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,20 @@ | |||
| #include <iostream> | ||||
| 
 | ||||
| using std::cout, std::endl; | ||||
| 
 | ||||
| struct Book { | ||||
|     char title[100]; | ||||
|     int pages; | ||||
|     float price; | ||||
| }; | ||||
| 
 | ||||
| void addPrice(Book& b, float x) { | ||||
|     b.price += x; | ||||
| } | ||||
| 
 | ||||
| int main() { | ||||
|     Book b = {"One Hundred Years of Solitude", 456, 1200}; | ||||
|     float x = 15.6; | ||||
|     addPrice(b, x); | ||||
|     cout << b.price << endl; | ||||
| } | ||||
		Reference in a new issue