Monday, July 27, 2009

Build a class about vector with java or c?

can you help me build a class about vector(and alll its functions built in methods, eg: dot product, cross product, normalization, etc)? i know java has vector class built in already, but it's a homework and we have to write the source codes. Any help is welcomed.

Build a class about vector with java or c?
/*


Data, function, and access class


Written by Hexonflux AKA Void


Enjoy.





Compiled successfully using Dev-C++.


Code written in C++


*/


#include %26lt;iostream%26gt;


#include %26lt;string%26gt;


#include %26lt;conio.h%26gt;





using namespace std;








//Create class


class myClass


{


public:


string someString;





int someFunction()


{


cout %26lt;%26lt; "someFunction called\n";


return 0;


}


};








int main()


{


//Identify class and assign it to MC


myClass MC;





//Class the variable someString and assign it a value


MC.someString = "This is a string\n";





//Call the variable someString from MC (myClass) and display it


cout %26lt;%26lt; "String: " %26lt;%26lt; MC.someString;





//Call the function someFunction from MC (myClass)


MC.someFunction();





//Press any key to continue


getch();


}








Enjoy,


- Void


No comments:

Post a Comment