C + + Object oriented

Source: Internet
Author: User

  1. If there is no argument constructor in the class, the compiler automatically creates one that, if no destructor is created, creates the destructor that should be displayed if the data field has an object type
  2. Copy constructors and Assignment symbols (=) are shallow copies (basic types by value, reference types by reference)
  3. A function is implemented as a class declaration and automatically becomes an inline function
  4. inline is a "keyword for implementation" and not a "keyword for declaration" keyword. inline must be placed with the function definition body to make the function inline, and only inline is placed in front of the function declaration without any effect .
  5. (*this). Radius = This->radius
  6. String class

    String operator: [],=,+,+=,<<,>>,==,!=,<,>,<=,>=

    ???? s[2]=s.at (2);

  7. Object passing is passed by value, and can be added & by reference
  8. Constructor initialization list

    ClassName (parameterlist): Datafield1 (value1), Datafield2 (value2) {}

    Circle::circle (): Radius (1) {} = Circle::circle () {radius = 1;}

    class, the const constant must be initialized in the initialization list and cannot be initialized with an assignment.

  9. #ifndef Classname_h

    #define Classname_h

    #endif

  10. static variables, static functions can be accessed either through ClassName::, or through class objects.
  11. Friend Friend

    One-to-one: compositing one-to-many: aggregations ()

  12. Vector-like vectors are more flexible than arrays vectotnmae.at (i) =vectornaem[i] <vector>
  13. When a subclass calls a base class constructor, it can only be called in the implementation and cannot be called in the declaration (the base class no argument constructor is called automatically when the call is not displayed)
  14. constructor connection, destructor connection
  15. The function overrides the//circle. Geometric::tostring ();
  16. polymorphic, dynamic binding virtual, the implementation of dynamic binding must ensure that the top-level base class function is a virtual function, and the parameter is a reference or pointer, the virtual function in the base class is automatically virtual in the subclass, do not have to display the declaration
  17. Public,protected,private
  18. Abstract functions (pure virtual functions, not implemented when declared, implemented in subclasses) virtual double gerarea () = 0;

    Classes with abstract functions are abstract classes, and abstract classes cannot declare specific instances

  19. Dynamic type conversion Circle *p=dynamic_cast<circle*> (p);
  20. typeID (*p or X). Name ()
  21. Ofstream object Open file Clears file contents close () fail () EOF ()
  22. Input.getline (city,40, ' # ')
  23. Char Get () | IStream * Get (char &ch) read in CH

    Char get (char array[],int size, char Delimitchar) read to array

    Will add a getline at the end ()

  24. void put (char ch)//output.put (Input.get ());
  25. FStream Mode Open File http://www.cnblogs.com/summerRQ/articles/2375747.html
  26. The Getline function is declared in <iostream>:

    Istream::getline
    istream& Getline (char* s, streamsize N);
    istream& Getline (char* s, streamsize N, Char delim)
    ;

  27. The Getline function is declared in the <string> header file :

    istream& Getline (istream& is, string& str, char delim);
    istream& Getline (istream& is, string& str);

  28. <fstream> Detection Flow Status Http://zh.cppreference.com/w/cpp/io/basic_fstream
  29. Streamobject.write (char * ch, int size)

    Binaryio.write (Reinterpret_cast<char *> (&value), sizeof (value));

    Streamobject.read (char * ch, int size)

  30. SEEKG () output, SEEKP () input

    Http://zh.cppreference.com/mwiki/index.php?title=Special%3A%E6%90%9C%E7%B4%A2&search=seek

  31. r1.operator< (r2) = R1 < R2 not overloaded? : . .* ::
  32. operator double ();
  33. catch (Type)
  34. <exception><stdexcept>
  35. Template<typename t> template<typename t=int, int capacity>

C + + Object oriented

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.