一个基本概念,C++只是一门语言,它除了有标准的输入/输出,并没有图形功能的一个最基本的例子,在单片机上用C++编程,它都没有图形输出,怎么写图形程序当然,C++可用来编写游戏甚至大型3D游戏。所以它肯定是可以编写有图形的程序的这个与操作系统有关了(C++可以运行在多个系统或平台上)在windows下,C++可以通过调用系统的SDK来编写图形程序(有点复杂)当然,也可通过第三方的库如MFC,QT,VCL,甚至easyx来编写图形程序如easyx的程序(要安装easyx环境的)#include <graphics.h>#include <conio.h>// 主函数int main(){ IMAGE img; // 绘图环境初始化 initgraph(640, 480); // 读取图片至绘图窗口 loadimage(&img, "1.jpg", 640, 480); putimage(0, 0, &img); // 按任意键退出 _getch(); closegraph();}而一个完整的windows程序(显示一个二维码,纯windows开发)如下#include <windows.h>/* This is where all the input to the window goes to */char data[35][36]={ "00000000000000000000000000000000000", "01111111011101111010101110011111110", "01000001010001100010101110010000010", "01011101001111100001001100010111010", "01011101010011100011011110010111010", "01011101010011010000100101010111010", "01000001011000001110111100010000010", "01111111010101010101010101011111110", "00000000000110101001111110000000000", "00001001001010000100101011001110110", "00101010011110100001110000001111000", "00100001111000011001010010011111100", "01100100110011000010111100000011010", "00110011010111011000000110010001000", "00011110000000110101101110100100110", "00011101110111000001000100111011010", "00100100110101010010101001110011110", "00001011001100011010001000101111010", "01011110100001000001110110011100010", "00111011111001100101111111000111100", "00011110100011000110011100001100100", "00011101110010001011111111100001110", "00000010000100010011010000100110100", "01101101001010110001010010001011110", "00110110111001100111110010011110010", "01010111101100100110001011111101100", "00000000010100100011010011000101110", "01111111000110011001100101010111000", "01000001000100100101011011000101010", "01011101001010010101110001111111100", "01011101010000111101101010101101010", "01011101001101010110011011001010010", "01000001000100010101000100101100010", "01111111001001011110100011010011000", "00000000000000000000000000000000000"};LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam){ switch(Message) { /* Upon destruction, tell the main thread to stop */ case WM_DESTROY: { PostQuitMessage(0); break; } case WM_PAINT: { char c; int x,y; HDC dc=GetDC(hwnd); for(x=0; x<35*4; x++) for(y=0; y<35*4; y++) { c=data[x/4][y/4]; if (c=='0') SetPixel(dc,x,y,0x00ffffff); else SetPixel(dc,x,y,0x00FF0000); } break; } /* All other messages (a lot of them) are processed using default procedures */ default: return DefWindowProc(hwnd, Message, wParam, lParam); } return 0;}/* The 'main' function of Win32 GUI programs: this is where execution starts */int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){ WNDCLASSEX wc; /* A properties struct of our window */ HWND hwnd; /* A 'HANDLE', hence the H, or a pointer to our window */ MSG msg; /* A temporary location for all messages */ /* zero out the struct and set the stuff we want to modify */ memset(&wc,0,sizeof(wc)); wc.cbSize = sizeof(WNDCLASSEX); wc.lpfnWndProc = WndProc; /* This is where we will send messages to */ wc.hInstance = hInstance; wc.hCursor = LoadCursor(NULL, IDC_ARROW); /* White, COLOR_WINDOW is just a #define for a system color, try Ctrl+Clicking it */ wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszClassName = "WindowClass"; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); /* Load a standard icon */ wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); /* use the name "A" to use the project icon */ if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!","Error!",MB_ICONEXCLAMATION|MB_OK); return 0; } hwnd = CreateWindowEx(WS_EX_CLIENTEDGE,"WindowClass","Test",WS_VISIBLE|WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, /* x */ CW_USEDEFAULT, /* y */ 35*4+30, /* width */ 35*4+50, /* height */ NULL,NULL,hInstance,NULL); if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!","Error!",MB_ICONEXCLAMATION|MB_OK); return 0; } /* This is the heart of our program where all input is processed and sent to WndProc. Note that GetMessage blocks code flow until it receives something, so this loop will not produce unreasonably high CPU usage */ while(GetMessage(&msg, NULL, 0, 0) > 0) /* If no error is received... */ { TranslateMessage(&msg); /* Translate key codes to chars if present */ DispatchMessage(&msg); /* Send it to WndProc */ } return msg.wParam;}