MoinMoin Logo
  • Comments
  • Immutable Page
  • Menu
    • Navigation
    • RecentChanges
    • FindPage
    • Local Site Map
    • Help
    • HelpContents
    • HelpOnMoinWikiSyntax
    • Display
    • Attachments
    • Info
    • Raw Text
    • Print View
    • Edit
    • Load
    • Save
  • Login

Navigation

  • Start
  • Sitemap
Revision 4 as of 2018-09-10 17:17:07
  • CPlusPlus

CPlusPlus

C++ programming language created by Bjarne Stroustrup

Sample app for Linux

   1 /*
   2 gcc test.cpp -lstdc++ -o test
   3 cpp test.cpp -o test
   4 g++ test.cpp -o test
   5 */
   6 
   7 #include<vector>
   8 #include<iostream>
   9 #include<sstream>
  10 
  11 class Teste{
  12   public:
  13     Teste(std::string xyz){
  14       std::cout << xyz << "\r\n";
  15     }
  16 };
  17 
  18 int main(){
  19   std::vector<int> listInst = std::vector<int>(); 
  20   std::cout <<"Hello world \r\n";
  21   std::ostringstream oss(std::ostringstream::out);
  22   int a = 1234;
  23   char xpto[16]="AAA BBB";
  24   oss << a << xpto << "\r\n";
  25 
  26   std::cout << oss.str();
  27   //std::ostringstream ost = std::ostringstream(ostringstream::out);
  28   Teste x1("Ola aaaaaaa");
  29   return 0;
  30 }
  31 
  32 /*
  33 To compile in gcc container
  34 g++ test.cpp -o test
  35 
  36 g++ (GCC) 8.2.0
  37 */
  38 #include<vector>
  39 #include<iostream>
  40 #include<sstream>
  41 #include<random>
  42 #include<ctime>
  43 
  44 class Teste{
  45   public:
  46     Teste(std::string xyz){
  47       std::cout << xyz << "\r\n";
  48     }
  49 };
  50 
  51 int main(){
  52   std::vector<int> listInst = std::vector<int>();
  53   std::cout <<"Hello world \r\n";
  54   std::ostringstream oss(std::ostringstream::out);
  55   int a = 1234;
  56   char xpto[16]="AAA BBB";
  57   oss << a << xpto << "\r\n";
  58 
  59   std::cout << oss.str();
  60   //std::ostringstream ost = std::ostringstream(ostringstream::out);
  61   Teste x1("Ola aaaaaaa");
  62   srand( (unsigned) time(0)  );
  63   std::cout << rand() <<"\n";
  64   std::cout << rand() <<"\n";
  65   std::cout << std::to_string(1234) << " " << std::to_string(34.56) << "\n";
  66   return 0;
  67 }
  • MoinMoin Powered
  • Python Powered
  • GPL licensed
  • Valid HTML 4.01