Results 1 to 6 of 6

Thread: C++ -

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date: Oct:2008
    Location:
    Posts: 95

    C++ -

    ,

    C++ , . , . , :
    1.
    Code:
    #include <iostream>
    using namespace std;
    
    std::string str_return(std::string &in)
    {
        std::string temp= in;
        return temp;
    }
    
    int main ()
    {
      std::string s = "Mnogo eleni sa se navydili";
      cout << str_return(s) << endl;
    }
    , in:
    Code:
    std::string str_return(std::string in)
    in &in ?

    2. :
    char * s = "Dryn dryn dryn";
    char s []= "Dryn dryn dryn";

    3. :
    int * x;
    int* x;
    int *x;
    (int *) x;
    int (* x);

    , .
    !

  2. #2
    ɐ-əpoɔᴉu⋂ ɐ ə anrieff's Avatar
    Join Date: Apr:2004
    Location: Sofia
    Posts: 8,448
    1. . &in str_return(), .
    (str_return_ref &):

    Code:
    #include <iostream>
    using namespace std;
    
    std::string str_return(std::string in)
    {
        in += ", bre!";
        std::string temp= in;
        return temp;
    }
    
    std::string str_return_ref(std::string& in)
    {
        in += ", bre!";
        std::string temp= in;
        return temp;
    }
    
    int main ()
    {
      std::string s = "Mnogo eleni sa se navydili";
      cout << str_return(s) << endl; //   "Mnogo eleni sa se navydili, bre!"
      cout << s << endl; //   "Mnogo eleni sa se navydili" (s   )
      cout << str_return_ref(s) << endl; //   "Mnogo eleni sa se navydili, bre!"
      cout << s << endl; //   "Mnogo eleni sa se navydili, bre!" (s  ).
    }
    2.

    3. , 4- - cast, .. int. , unsigned int*, int*.
    .
    , . .
    "640K ught to be enough for anybody" - Bill Gates, 1981
    ::Machine specs::Fract::AGG::::Baileys::blog::YouTube channel

  3. #3
    Registered User martinhr's Avatar
    Join Date: Jul:2008
    Location: /dev/random
    Posts: 331
    malloc, void pointer void pointer .Type casting e ASCII char.
    ThinkPad T520 ( 4243F53 ) | Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz | Crucial 8GB Ballistix Sport DDR3 @ 1333MHz | SAMSUNG 850 Pro Series ( MZ-7KE128BW ) 128GB 3-D Vertical | Seagate FireCuda Gaming SSHD 2TB ( ST2000LX001 ) | Kernel: 4.4.0-24-generic x86_64 Distro: Ubuntu 16.04 xenial

  4. #4
    Registered User
    Join Date: Feb:2006
    Location: Plovdiv
    Posts: 392
    Quote Originally Posted by martinhr View Post
    malloc, void pointer void pointer .Type casting e ASCII char.
    , ++.

  5. #5
    Registered User martinhr's Avatar
    Join Date: Jul:2008
    Location: /dev/random
    Posts: 331
    , malloc, new.
    ThinkPad T520 ( 4243F53 ) | Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz | Crucial 8GB Ballistix Sport DDR3 @ 1333MHz | SAMSUNG 850 Pro Series ( MZ-7KE128BW ) 128GB 3-D Vertical | Seagate FireCuda Gaming SSHD 2TB ( ST2000LX001 ) | Kernel: 4.4.0-24-generic x86_64 Distro: Ubuntu 16.04 xenial

  6. #6
    Nuclear's Avatar
    Join Date: Sep:2004
    Location: , . ()
    Posts: 3,352
    Quote Originally Posted by PhrozenCrew View Post

    2. :
    char * s = "Dryn dryn dryn";
    char s []= "Dryn dryn dryn";
    , s . , (read only) . ., ( strcpy(s,"alabala") ). .

    - . , , .

    3 , :

    1. .
    2. , : :
    int *a, b; int, b int.
    . HWBG !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |