First dynamic_cast:
Copy Code code as follows:
#include
using namespace Std;
Class a{
Public
Virtual ~a () {}//use dynamic_cast when necessary!
};
Class B:public a{
Public
B () {
m_b=12;
}
void Foo () {
cout}
Private
int
ProblemTurn off the lights.
There were n lights, numbered 1~n, and the 1th man turned all the lights on, the 2nd person presses all switches with multiples of 2 (these lights will be turned off), and the 3rd person presses all switches numbered 3
Topic: The Fibonacci number is defined as: F (0) =0,f (1) =1,f (n) =f (n-1) +f (n-2) (N>1 and N is an integer)
If you write the Phillips series, it should be:
0 1 1 2 3 5 8 13 21 34 ...
If the 6th item is to be asked, it shall be 8.
Find the nth
The system () function is powerful, and many people use it with little knowledge of the Linux version of the system function first:
Copy Code code as follows:
#include
#include
#include
#include
int system (const char *
Screening method
Introduced:Screening method, also called Sieve method, is a method to find all prime numbers of natural number N (n>1). It is said that the ancient Greek Eratosthenes (Eratosthenes, about 274-194 BC) invented, also known as
1. Matrix addition
Two identical matrices do addition, that is, the corresponding elements are added.
Copy Code code as follows:
#include
using namespace Std;
int main () {
int a[3][3]={{1,2,3},{6,5,4},{4,3,2}};
int b[3][3]={{4,3,2},
C + + memory is divided into stacks, heap areas, global/static areas, string constants, and code areas.
This removes the free storage area and adds a code area, which is the reason for the following.
Stack Area: memory management by the system.
C + + to implement a simple student management system
Student.cpp
#include
using namespace std;
struct Stu
{
char no[10];
Char name[16];
int math;
int Chi;
Double Ave;
};
Class Student
{public
:
Stu St;
Student *
Class is an abstraction of an object, we can use a class to define many objects, and each object has its own attributes.
When we use classes to define objects with many of the same structure, we can take the object array method.
For example, there
How to use:(1) When a function is declared or defined, the parameter is assigned a value directly, which is the default parameter.(2) When a function is called, omit some or all of the arguments, and the default arguments are used instead.
Note:(1)
#include
class Test
{
private:
int i;
Int J;
int k;
Public:
void Initialize ()
{
i=0;
J=1;
k=2;
}
void print ()
{
printf ("i=%d,j=%d,k=%d", i,j,k);
}
};///semicolon critical
int main ()
{
Test T1;
T1.initialize (); constructor
Dynamically created buttons are processed in the message OnCommand, regardless of the message, will be processed
1\ Create button
Copy Code code as follows:
cbutton* btn = new CButton ();
Btn->create (_t ("method"), Ws_child |
The first time to write a program in C + + is only a rookie level of C #, but very familiar with C #. There is a great similarity between the two. But there are also differences.
First wrote a network communication with a small MFC program. Found
(
1\ when developing a project, use the ListControl control, for some questions, make a note for later use
(1) Delete all project Deleteallitems () to the list item;
(2) Add a column to the list item. InsertColumn (0, _t ("number"));
(3) Set the
AfxBeginThread
Both the user interface thread and the worker thread are created by AfxBeginThread. Now, look at the function: MFC provides two overloaded versions of AfxBeginThread, one for user interface threads and another for worker threads,
The example in this article describes the C language connection and operation of Sedna XML databases. Share to everyone for your reference. as follows:
#include "libsedna.h" #include "stdio.h" int handle_error (sednaconnection* conn, const
Load a bit diagram, you can use LoadImage:
HANDLE LoadImage (hinstance hinst,lpctstr lpszname,uint utype,int);LoadImage can be used to load bitmaps, icons, and cursors
Loading can specify the mapping of the load graph to the size of memory:
Write a program that counts the number of rows in the Data.txt file, and then writes all lines preceded by a line number to the Data1.txt file.
Algorithm hints:
Rows and rows are separated by a carriage return, while the getline () function
This paper mainly records the inline function in C + +, that is, the inline function, mainly recorded the following problems:
Why does C + + introduce inline function?
The main purpose is to use it instead of the macro definition in the form of
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