``````#include <stdio.h>
#define INFINITY 2147483647  //最大值∞
#define MAX_VERTEX_NUM 20    //最大顶点数

//图的种类
typedef enum{
DG,DN,UDG,UDN     //有向图，有向网，无向图，无向网
}GraphKind;
//弧的定义
typedef struct Arc{
int arcvalue;                               //弧值
//这里可加 *info表示弧的其它信息
//图的结构
typedef struct MGraph{
int vexs[MAX_VERTEX_NUM];           //顶点值
int vexnum,arcnum;                  //图当前的顶点数和弧数
GraphKind kind;                     //图的种类标志
}MGraph;
//建立图的邻接表，邻接矩阵
void CreateUDG(MGraph &G);

//构造邻接矩阵
void CreateGraph(MGraph &G)
{
scanf("%s",&G.kind);  //输入图的种类
switch(G.kind){
case UDG:CreateUDG(G);
default:printf("输入错误,请输入（DG,DN,UDG,UDN）");
}
}
//构造无向图
void CreateUDG(MGraph &G)
{
int i,j;
scanf("%d %d",&G.vexnum,&G.arcnum); //这里可以加个&IncInfo来表示弧有没有其它信息（0或1）
for(i=0;i<G.vexnum;i++)
scanf("%d",&G.vexs[i]);         //构造顶点向量；
for(i=0;i<G.vexnum;i++)
for(j=0;j<G.vexnum;j++)
G.arcs[i][j]=INFINITY;

}
``````

1个回答

vc6编译tixmlnode时出现运算符重载错误
vc6编译tixmlnode出现错误： ticpp.h(999) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class TiXmlNode' (or there is no acceptable conversion) ticpp.h(1008) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class TiXmlNode' (or there is no acceptable conversion) ![图片说明](https://img-ask.csdn.net/upload/201710/30/1509330754_609974.png) 但是看代码类class TiXmlNode是有重载运算符<< 和 >>的，去掉其中的宏定义还是编译不过，求帮助

void CWrite2View::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default m_ptStart=point; m_ptEnd=point; SetCapture(); m_isDragging=true; CListView::OnLButtonDown(nFlags, point); } 错误信息： C:\Users\john\Desktop\VChh\MyProjects\Write2\Write2View.cpp(111) : error C2065: 'm_ptStart' : undeclared identifier C:\Users\john\Desktop\VChh\MyProjects\Write2\Write2View.cpp(111) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class CPoint' (or there is no acceptable conversion) C:\Users\john\Desktop\VChh\MyProjects\Write2\Write2View.cpp(112) : error C2065: 'm_ptEnd' : undeclared identifier C:\Users\john\Desktop\VChh\MyProjects\Write2\Write2View.cpp(112) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class CPoint' (or there is no acceptable conversion) C:\Users\john\Desktop\VChh\MyProjects\Write2\Write2View.cpp(114) : error C2065: 'm_isDragging' : undeclared identifier C:\Users\john\Desktop\VChh\MyProjects\Write2\Write2View.cpp(131) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class CPoint' (or there is no acceptable conversion) 执行 cl.exe 时出错.

[](http://xingbinice.iteye.com/blog/1894710 "") 这个网页中的代码，我复制下来之后粘贴在VC++，出现了这样的错误。怎么修改才能在VC++中运行呢？希望能把修改好之后的代码发出来。 --------------------Configuration: Cpp1 - Win32 Debug-------------------- Compiling... Cpp1.cpp c:\users\administrator\desktop\cpp1.cpp(46) : error C2065: 'assert' : undeclared identifier c:\users\administrator\desktop\cpp1.cpp(599) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptab le conversion) c:\users\administrator\desktop\cpp1.cpp(601) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptab le conversion) c:\users\administrator\desktop\cpp1.cpp(602) : error C2676: binary '==' : 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' does not define this operator or a conversion to a type acceptable to the predefined operator c:\users\administrator\desktop\cpp1.cpp(602) : error C2676: binary '==' : 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' does not define this operator or a conversion to a type acceptable to the predefined operator 执行 cl.exe 时出错. Cpp1.exe - 1 error(s), 0 warning(s)

Error parsing XML: junk after document element
c++模版不可识别的模板声明/定义
#include <iostream> using namespace std; template<typename Entry> struct Binary_node { public: Binary_node(); Binary_node(const Entry & x); private: Entry data; Binary_node<Entry> *left; Binary_node<Entry> *right; }; template<typename Entry> class Binary_tree { public: Binary_tree(); ~Binary_tree(); void Layer_order(Binary_node<Entry> & x); Binary_node<Entry>* getRoot(); protected: Binary_node<Entry> *root; }; template<typename Entry> Binary_tree<Entry>::Binary_tree() { } template<typename Entry> Binary_tree<Entry>::~Binary_tree() { } template<typename Entry> void Binary_tree<Entry>::Layer_order(Binary_node<Entry> & x ) { } template<typename Entry> Binary_node<Entry>* Binary_Tree<Entry>::getRoot() { return root; } int main(void) { Binary_tree<int> binarytree; binarytree.Layer_order(*(binarytree.getRoot())); return 0; } 错误 2 error C2988: 不可识别的模板声明/定义 e:\exercise of programming\datastructrue+cpp\test_empty\test_empty\test.cpp 53 1 TEST_empty 错误 6 error C2447: “{”: 缺少函数标题(是否是老式的形式表?) e:\exercise of programming\datastructrue+cpp\test_empty\test_empty\test.cpp 60 1 TEST_empty 错误 1 error C2143: 语法错误 : 缺少“;”(在“<”的前面) e:\exercise of programming\datastructrue+cpp\test_empty\test_empty\test.cpp 53 1 TEST_empty 错误 5 error C2143: 语法错误 : 缺少“;”(在“{”的前面) e:\exercise of programming\datastructrue+cpp\test_empty\test_empty\test.cpp 60 1 TEST_empty 错误 3 error C2059: 语法错误:“<” e:\exercise of programming\datastructrue+cpp\test_empty\test_empty\test.cpp 53 1 TEST_empty 错误 4 error C2039: “getRoot”: 不是“`global namespace'”的成员 e:\exercise of programming\datastructrue+cpp\test_empty\test_empty\test.cpp 53 1 TEST_empty
android studio真机运行没问题，genymotion运行报错

``` #include<iostream> #include<conio.h> #include<string.h> #define OK 1 #define MAXSIZE 100 using namespace std; typedef int Status; typedef struct { char name[5]; float price; }Book; typedef Book ElemType; typedef struct { ElemType *elem; int length; }SqList; Status InitList(SqList &L) { //L.elem=new ElemType[MAXSIZE]; L.elem=new ElemType[MAXSIZE]; if(!L.elem) exit(-1); L.length=0; return OK; } Status GetList(SqList L,int i,ElemType &book) { if(i<1||i>L.length) exit(-1); else book=L.elem[i-1]; return OK; } int LocateElem(SqList L,ElemType e) { int i; for( i=0;i<L.length;i++) if(L.elem[i]==e) return i+1; return 0; } int main() { SqList L; InitList(L); L.elem[0].price=0; L.length++; L.elem[1].price=1; L.length++; ElemType ceshi; GetList(L,2,ceshi); LocateElem(L,ceshi); cout<<ceshi.price; getch(); return 0; } ``` 这是我写的代码，编译后报错 --------------------Configuration: 线性表 - Win32 Debug-------------------- Compiling... 线性表.cpp E:\数据结构\线性表.cpp(41) : error C2784: 'bool __cdecl std::operator ==(const class std::allocator<_Ty> &,const class std::allocator<_U> &)' : could not deduce template argument for 'const class std::allocator<_Ty> &' from 'Book' E:\数据结构\线性表.cpp(41) : error C2784: 'bool __cdecl std::operator ==(const class std::istreambuf_iterator<_E,_Tr> &,const class std::istreambuf_iterator<_E,_Tr> &)' : could not deduce template argument for 'const class std::istreambuf_iterator<_ E,_Tr> &' from 'Book' E:\数据结构\线性表.cpp(41) : error C2784: 'bool __cdecl std::operator ==(const class std::reverse_iterator<_RI,_Ty,_Rt,_Pt,_D> &,const class std::reverse_iterator<_RI,_Ty,_Rt,_Pt,_D> &)' : could not deduce template argument for 'const class std::rev erse_iterator<_RI,_Ty,_Rt,_Pt,_D> &' from 'Book' E:\数据结构\线性表.cpp(41) : error C2784: 'bool __cdecl std::operator ==(const struct std::pair<_T1,_T2> &,const struct std::pair<_T1,_T2> &)' : could not deduce template argument for 'const struct std::pair<_T1,_T2> &' from 'Book' E:\数据结构\线性表.cpp(41) : error C2676: binary '==' : 'Book' does not define this operator or a conversion to a type acceptable to the predefined operator Error executing cl.exe. 线性表.exe - 5 error(s), 0 warning(s) 经过测验，是查找线性表函数LocateList中的if(L.elem[i]==e)发生错误，也就是结构体匹配出现了问题，请问完成结构体匹配，代码该如何修改呢？
C++ 编译错误：error: invalid operands of types 'double***' and 'double' to binary 'operator/'？
error: invalid operands of types 'double***' and 'double' to binary 'operator/' 源代码是这样的： void Porous::Compute_Force(Flow_solver* Flow, Parallel_MPI* MPI_parallel) { int X, Y, Z; double F_epsilon; if (processor_id != MASTER) { for (X = 2; X <= MPI_parallel->actual_rows_XYZ[0]+1; ++X) { for (Y = 2; Y <= MPI_parallel->actual_rows_XYZ[1]+1; ++Y) { for (Z = 2; Z <= MPI_parallel->end_XYZ2[2]+1; ++Z) { F_epsilon = 1.75 / sqrt( 150 * pow(Porosity[X][Y][Z],3) ); Flow->force[X][Y][Z][0] = Porosity[X][Y][Z] * (Flow->viscosity/Permeability[X][Y][Z] - F_epsilon * Flow->velocity_magnitude[X][Y][Z]/sqrt(Permeability[X][Y][Z]) ) * Flow->velocity[X][Y][Z][0] + Porosity[X][Y][Z] * Flow->force[X][Y][Z][0]; Flow->force[X][Y][Z][1] = Porosity[X][Y][Z] * ( Flow->viscosity/Permeability[X][Y][Z] - F_epsilon * Flow->velocity_magnitude[X][Y][Z] / sqrt(Permeability[X][Y][Z]) ) * Flow->velocity[X][Y][Z][1] + Porosity[X][Y][Z] * Flow->force[X][Y][Z][1]; Flow->force[X][Y][Z][2] = Porosity[X][Y][Z] * ( Flow->viscosity / Permeability[X][Y][Z] - F_epsilon * Flow->velocity_magnitude[X][Y][Z] / sqrt(Permeability[X][Y][Z]) ) * Flow->velocity[X][Y][Z][2] + Porosity[X][Y][Z] * Flow->force[X][Y][Z][2]; } } } } }
caffe生成解决方案时出错

C++导入*.h头文件后 出现LNK2001无法解析的外部符号 含有opencv库
seg.h 头文件导入至 Cpig.cpp文件后出现如下错误： ``` 1>------ 已启动生成: 项目: AnimalsFatMeasure, 配置: Release x64 ------ 1>Cpig.cpp 1>seg.cpp 1>Cpig.obj : error LNK2001: 无法解析的外部符号 "class cv::Mat g_srcImage" (?g_srcImage@@3VMat@cv@@A) 1>Cpig.obj : error LNK2001: 无法解析的外部符号 "class cv::Mat g_grayImage" (?g_grayImage@@3VMat@cv@@A) 1>D:\AnimalsFatMeasure\AnimalsFatMeasure\x64\Release\AnimalsFatMeasure.exe : fatal error LNK1120: 2 个无法解析的外部命令 ``` ```cpp //seg.h #ifndef __SEG_H__ #define __SEG_H__ #include"stdafx.h" #include <iostream> #include<opencv2\opencv.hpp> #include<opencv2/imgproc/imgproc.hpp> #include<vector> #include<math.h> #include<algorithm> #include<time.h> #include<io.h> #include<stdio.h> #include<string> using namespace cv; using namespace std; extern Mat g_srcImage; extern Mat g_grayImage; inline void ImageLoad(string imagefile) { Mat ori_image = imread(imagefile, 0); Rect rect(100, 100, 540, 400); ori_image = ori_image(rect);//截取图像 threshold(ori_image, ori_image, 1, 255, CV_THRESH_BINARY);//二值化 //threshold(ori_image, ori_image, g_nThresh, g_nMaxThresh, CV_THRESH_BINARY);//二值化 //waitKey(0); imwrite("binaryimg.jpg", ori_image); g_srcImage = imread("binaryimg.jpg", 1); if (!g_srcImage.data) { printf("读取错误，图片不存在"); } //得到原图的灰度图并进行平滑 //Point point; cvtColor(g_srcImage, g_grayImage, COLOR_BGR2GRAY); blur(g_grayImage, g_grayImage, Size(3, 3)); on_ContourChange(0, 0); } ``` ```cpp // Cpig.cpp: 实现文件 #include <opencv2/opencv.hpp> #include "stdafx.h" #include "Cpig.h" #include "afxdialogex.h" #include "resource.h" #include <algorithm> #include <fstream> #include <string> #include <windows.h> #include <iostream> #include "INFOR.h" #include "seg.h" ```
linux下生成的bin文件 在板子上运行出错

kafka-node报Snappy codec is not installed

Java学习的正确打开方式

linux系列之常用运维命令整理笔录

Python十大装B语法
Python 是一种代表简单思想的语言，其语法相对简单，很容易上手。不过，如果就此小视 Python 语法的精妙和深邃，那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点，并附上详细的实例代码。如能在实战中融会贯通、灵活使用，必将使代码更为精炼、高效，同时也会极大提升代码B格，使之看上去更老练，读起来更优雅。

Docker 技术发展为微服务落地提供了更加便利的环境，使用 Docker 部署 Spring Boot 其实非常简单，这篇文章我们就来简单学习下。首先构建一个简单的 S...

SQL-小白最佳入门sql查询一

redis分布式锁，面试官请随便问，我都会

Nginx 原理和架构
Nginx 是一个免费的，开源的，高性能的 HTTP 服务器和反向代理，以及 IMAP / POP3 代理服务器。Nginx 以其高性能，稳定性，丰富的功能，简单的配置和低资源消耗而闻名。 Nginx 的整体架构 Nginx 里有一个 master 进程和多个 worker 进程。master 进程并不处理网络请求，主要负责调度工作进程：加载配置、启动工作进程及非停升级。worker 进程负责处...
“狗屁不通文章生成器”登顶GitHub热榜，分分钟写出万字形式主义大作

《程序人生》系列-这个程序员只用了20行代码就拿了冠军

11月8日，由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办，科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。 　　区块链技术被认为是继蒸汽机、电力、互联网之后，下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力，电力解决了人类基本的生活需求，互联网彻底改变了信息传递的方式，区块链作为构造信任的技术有重要的价值。 　　1...
Java世界最常用的工具类库
Apache Commons Apache Commons有很多子项目 Google Guava 参考博客

【技巧总结】位运算装逼指南

Android 9.0 init 启动流程