当我在Vim工作时,我想对php标签内的所有代码进行轻微的背景颜色更改.因此,例如,对于常规XHTML标记,背景是纯黑色,然后在php标记内显示轻微的亮度,以帮助我快速识别它.这是我可以/应该使用配色方案还是有其他方法?
这段代码:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!\n";
return 0;
}
Run Code Online (Sandbox Code Playgroud)
当com ::在GCC 4.4.1的Code :: Blocks中给出大小为457KB,在VS2010中只有8KB(8).这两个编译器都针对大小进
谁知道为什么会有这样的差异?
可能重复:
主函数可以在C++中调用自身吗?
我决定使用CodeBlock IDE通过调用main函数进行一个小测试,这应该是一个非法的行为.
EX:
#include <iostream>
using namespace std;
int main()
{
cout<<"hello"<<endl;
main();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
奇怪的是,在代码块中我能够编译这个混乱.有谁知道为什么?
输出:你好
我开始自学C++并且遇到了一个错误,我认为这个错误非常简单,但没有抓住它.我创建了以下名为EmployeeT.h的头文件
#ifndef EMPLOYEET_H_INCLUDED
#define EMPLOYEET_H_INCLUDED
typedef struct
{
char firstInitial;
char middleInitial;
char lastInitial;
int employeeNumber;
int salary;
} EmployeeT
#endif // EMPLOYEET_H_INCLUDED
Run Code Online (Sandbox Code Playgroud)
以主为
#include <iostream>
#inclide <Employee.h>
using namespace std;
int main()
{
EmployeeT anEmployee;
anEmployee.firstInitial = 'M';
anEmployee.middleInitial = 'R';
anEmployee.lastInitial = 'G';
anEmployee.employeeNumber = 42;
anEmployee.salary = 80000;
cout << "Employee: " << anEmployee.firstInitial <<
anEmployee.middleInitial <<
anEmployee.lastInitial << endl;
cout << "Number: " << anEmployee.employeeNumber << endl;
cout << "Salary: " << anEmployee.salary <<endl;
return 0; …Run Code Online (Sandbox Code Playgroud) 在尝试编译包含pthreads的代码时,我遇到了诸如下面提到的错误
warning: return type defaults to 'int' [-Wreturn-type]|
|In function 'print_message_function':|
warning: control reaches end of non-void function [-Wreturn-type]|
| undefined reference to `_imp__pthread_create'|
| undefined reference to `_imp__pthread_create'|
| undefined reference to `_imp__pthread_join'|
| undefined reference to `_imp__pthread_join'|
Run Code Online (Sandbox Code Playgroud)
我在Windows 7上运行GCC,但我安装了mingw.我正在使用IDE Code :: Blocks并选择"编译当前文件".这是链接器设置的屏幕截图,我在这里不知所措

更新:我添加-pthread到"其他链接器选项",它更好地工作.还有问题.当我编译它说
|In function 'print_message_function':|
warning: control reaches end of non-void function [-Wreturn-type]|
Run Code Online (Sandbox Code Playgroud)
当我去运行CodeBlocks说"看起来程序尚未构建",当我点击"build"时,我显示此错误
mingw32-g++.exe -o "SimpleExample.exe" "SimpleExample.o" -static-libgcc -static-libstdc++ -pthread
mingw32-g++.exe: error: unrecognized option '-pthread'
Process terminated with status 1 (0 minutes, 0 …Run Code Online (Sandbox Code Playgroud) 我成功安装并链接并包含OpenCV.(我知道它是成功的,因为我编译并运行了本网站上的opencv程序)
所以我回到了OpenCV文档和教程页面.我从这个页面复制了下面的确切代码.
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
if( argc != 2)
{
cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
return -1;
}
Mat image;
image = imread(argv[1], CV_LOAD_IMAGE_COLOR); // Read the file
if(!image.data ) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}
namedWindow( "Display window", WINDOW_AUTOSIZE );// Create a window …Run Code Online (Sandbox Code Playgroud) 我在使用我的c ++源文件或者编译器本身时遇到了一些奇怪的事情.似乎当我尝试编译文件时,它会给我发一条消息 -
未定义的引用"Basic_int_stack :: Basic_int_stack()
未定义的引用"Basic_int_stack :: Push(int)
这是我的代码(我还是初学者,所以不要指望任何疯狂的专业代码)
头文件:
class Basic_int_stack
{
public:
// This part should be implementation independent.
Basic_int_stack(); // constructor
void push( int item );
int pop();
int top();
int size();
bool empty();
private:
// This part is implementation-dependant.
static const int capacity = 10 ; // the array size
int A[capacity] ; // the array.
int top_index ; // this will index the top of the stack in the array
};
Run Code Online (Sandbox Code Playgroud)
实现:
#include "basic_int_stack.h"// …Run Code Online (Sandbox Code Playgroud) 我差不多整整一天都在寻找如何做到这一点.
起初,我认为这可以通过......来完成
Right click the project name -> "Add files" -> choosing a .cpp file which contains the class you need and the corresponding header file.
然后,.cpp文件和头文件与其原始文件夹一起出现.在此之后,我写#include"random.h"了一个需要使用的项目random.h及其功能.
但是,这会产生错误,表明这一点fatal error: random.h: No such file or directory.编译器显然找不到该文件(即使我可以).
我添加了这张照片.

另外,我一直在寻找如何在没有文件夹的情况下添加.cpp和头文件.(例如,在上图中,您将看到random.cpp内部Using_a_class_test包含在一个名为的文件夹中Random.令我遗憾的是,我还没有找到如何消除这样的文件夹.)
如果您提供任何见解,我将不胜感激.
我试图在c ++中添加一个块注释,但我创建了一个类型-o而/**不是写/*.我注意到里面的评论以粗体显示.有谁知道这意味着什么?
我一直在寻找解决方案,老实说,我被困住了。
我正在尝试安装Box2D,如文件路径所示。
无论如何,此提示在出现以下内容之前会出现几次:
The CXX compiler identification is unknown
Check for working CXX compiler: C:/MinGW/bin/g++.exe
Check for working CXX compiler: C:/MinGW/bin/g++.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.6/Modules/CMakeTestCXXCompiler.cmake:54 (message):
The C++ compiler "C:/MinGW/bin/g++.exe" is not able to compile a simple
test program.
It fails with the following output:
Change Dir: C:/Users/alexm/Documents/Box2D/Build/CMakeFiles/CMakeTmp
Run Build Command:"C:/MinGW/bin/mingw32-make.exe" "cmTC_31089/fast"
C:/MinGW/bin/mingw32-make.exe -f CMakeFiles\cmTC_31089.dir\build.make
CMakeFiles/cmTC_31089.dir/build
mingw32-make.exe[1]: Entering directory
'C:/Users/alexm/Documents/Box2D/Build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_31089.dir/testCXXCompiler.cxx.obj
C:\MinGW\bin\g++.exe -o CMakeFiles\cmTC_31089.dir\testCXXCompiler.cxx.obj
-c
C:\Users\alexm\Documents\Box2D\Build\CMakeFiles\CMakeTmp\testCXXCompiler.cxx
CMakeFiles\cmTC_31089.dir\build.make:64: recipe for target
'CMakeFiles/cmTC_31089.dir/testCXXCompiler.cxx.obj' failed
mingw32-make.exe[1]: *** …Run Code Online (Sandbox Code Playgroud)