我试图在C++中声明一个回调例程,如下所示:
void register_rename (int (*function) (const char *current, const char *new));
/*------------------------------------------------------------*/
/* WHEN: The callback is called once each time a file is received and
* accepted. (Renames the temporary file to its permanent name)
* WHAT: Renames a file from the given current name to the specified new name.
*/
Run Code Online (Sandbox Code Playgroud)
但是,我收到以下错误:
line 204: error #70:
incomplete type is not allowed
void register_rename (int (*function) (const char *current, const char *new));
Run Code Online (Sandbox Code Playgroud)
我不知道如何纠正这个问题.我在同一个头文件中声明了其他类似的回调例程,我没有收到此错误.
请帮忙!:)
使用Netbeans,我想把一个包放到另一个包中.例如,在Visual Studio 2008中,我可以拥有名为"Nodes"的文件夹,以及名为"Expressions"的Nodes中的另一个文件夹.我如何在Netbeans中这样做?我认为Java中的包相当于C#中的文件夹.
我试图使用一个在类中声明的枚举类型的类,如下所示:
class x {
public:
x(int);
x( const x &);
virtual ~x();
x & operator=(const x &);
virtual double operator()() const;
typedef enum {
LINEAR = 0, /// Perform linear interpolation on the table
DIPARABOLIC = 1 /// Perform parabolic interpolation on the table
} XEnumType;
};
Run Code Online (Sandbox Code Playgroud)
我需要声明这个类的实例并初始化枚举类型.我来自C#并且通常看到枚举为类的OUTSIDE,而不是INSIDE就像它在这里一样.如何初始化枚举类型.例如,我想做这样的事情:
x myX(10);
myX.XEnumType = Linear;
Run Code Online (Sandbox Code Playgroud)
显然这不起作用.我该怎么做?
我是Java的新手,我通过Eclipse在以下几行中收到错误:
import com.sun.mirror.apt.AnnotationProcessorFactory;
import com.sun.mirror.apt.AnnotationProcessor;
import com.sun.mirror.apt.AnnotationProcessorEnvironment;
Run Code Online (Sandbox Code Playgroud)
错误是"无法解析导入com.sun.mirror".
我该如何解决这个错误?
我今天遇到了一个有趣的问题.看看这个伪代码:
void Loop()
{
static int x = 1;
printf("%d", x);
x++;
}
void main(void)
{
while(true)
{
Loop();
}
}
Run Code Online (Sandbox Code Playgroud)
即使x是静态的,为什么这段代码每次只打印"1"?在打印之前,我在每次迭代时将x重新初始化为1.但无论出于何种原因,x按预期递增.
我需要将char*转换为整数.例如:
data.SetBytFldPos(*attribute->value());
Run Code Online (Sandbox Code Playgroud)
属性类中的值是char*.'SetBytFldPos'采用int.
我有一个奇怪的问题.我有一个矢量,我想把对象推到这样:
vector<DEMData>* dems = new vector<DEMData>();
DEMData* demData = new DEMData();
// Build DEMDATA
dems->push_back(*demData);
Run Code Online (Sandbox Code Playgroud)
向量中将有几百个DEMData对象.问题是当这段代码完成后,所有项目都等于最后一项"推回"到矢量?
为什么在向量中覆盖其他对象?
编辑:
DemData类很简单,只是一个带有setter和getter的数据结构:
class DEMData
{
private:
int bitFldPos;
int bytFldPos;
const char* byteOrder;
const char* desS;
const char* engUnit;
const char* oTag;
const char* valType;
int index;
public:
void SetIndex(int index);
int GetIndex() const;
void SetValType(const char* valType);
const char* GetValType() const;
void SetOTag(const char* oTag);
const char* GetOTag() const;
void SetEngUnit(const char* engUnit);
const char* GetEngUnit() const;
void SetDesS(const char* desS);
const …Run Code Online (Sandbox Code Playgroud) 我需要能够根据文件中的字节数设置数组的大小.
例如,我想这样做:
// Obtain the file size.
fseek (fp, 0, SEEK_END);
size_t file_size = ftell(fp);
rewind(fp);
// Create the buffer to hold the file contents.
char buff[file_size];
Run Code Online (Sandbox Code Playgroud)
但是,我得到一个编译时错误,说缓冲区的大小必须是常量.
我怎么能做到这一点?
我必须将16字节字段表示为数据结构的一部分:
struct Data_Entry
{
uint8 CUI_Type;
uint8 CUI_Size;
uint16 Src_Refresh_Period;
uint16 Src_Buffer_Size;
uint16 Src_CUI_Offset;
uint32 Src_BCW_Address;
uint32 Src_Previous_Timestamp;
/* The field below should be a 16 byte field */
uint32 Data;
};
Run Code Online (Sandbox Code Playgroud)
如何将"数据"字段表示为16字节字段而不是当前的4字节字段?
谢谢,
鲍比
我有一个脚本,我需要使用批处理文件执行.我是否在批处理文件中使用SQLCMD来运行脚本?此外,该脚本还将数据插入数据库中的表.我应该如何在批处理文件中格式化SQLCMD,以便它知道它可以使用哪个数据库?