Kod: |
#include<string> using namespace std; struct MyString{ char polje[100]; MyString( string ); void test( MyString ); }; |
Kod: |
#include<string> #include<iostream> #include "zeka.h" using namespace std; void MyString::test( MyString s ){ s.polje[1]='A'; cout << s.polje << endl; } MyString::MyString( string s ){ int brojac=0; if( s.size() > 99 ) cout << "String ima vise od 100 znakova!" << endl; else { for( string::iterator itr=s.begin(); itr!=s.end(); ++brojac ,++itr ) polje[brojac]=*itr; } polje[s.size()]='\0'; } |
Kod: |
#include<iostream> #include<string> #include "zeka.h" using namespace std; void main(){ MyString S( "XYZ" ); test( S ); cout << S.polje << endl; } |
Kod: |
#include<iostream> using namespace std; class cetverokut{ public: float a, b, c, d; cetverokut( void ); cetverokut( float, float, float, float ); float opseg( void ); ~cetverokut( void ){ cout << "Upravo smo \"de\"-konstruirali cetverokut!"; }; }; |
Kod: |
cetverokut::cetverokut( void ){ a=0, b=0, c=0, d=0; cout << "Upravo smo konstruirali cetverokut!" << endl; } |
Kod: |
cetverokut::cetverokut( float temp_a, float temp_b, float temp_c, float temp_d ){ if( temp_a > 0 ) a=temp_a; else{ cetverokut(); return; } if( temp_b > 0 ) b=temp_b; else{ cetverokut(); return; } if( temp_c > 0 ) c=temp_c; else{ cetverokut(); return; } if( temp_d > 0 ) d=temp_d; else{ cetverokut(); return; } cout << "Upravo smo konstruirali cetverokut!"; } |
output generated using printer-friendly topic mod. Vremenska zona: GMT + 01:00.