[C ++] object and pointer

Source: Internet
Author: User
# Include <iostream> using namespace STD; class time {public: Time (INT, Int, INT); int hour; int min; int sec; void get_time ();}; time: Time (int h, int M, int s) {hour = H; min = m; sec = s;} void time: get_time () {cout 

Problem:

Question 1: Why is an error reported when cout <P2 <Endl; is changed to cout <* P2 <Endl?
Question 2: cout <P3 <Endl; why is the value of P3 1? Is the memory address of the Public member function get_time () 1? Even 1 should be written in hexadecimal 000001 format.

Answer:

Problem 1: The out-of-class pair <is not overloaded, so * P2 (T1) cannot be output;

Question 2: Because the obtained address is of the void (A: *) () type, it is not a common pointer. Then use cout to output this type. cout may be used as a bool output directly.

Because cout <can accept so many types rely on heavy load, but it certainly does not have a void (A: *) () type overload

But try to use printf () to output and view the address.

After C ++, nothing else will be default.

C89 can be used without writing function return values or variable types. The default value is int.

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.