小编sil*_*ent的帖子

在类之外调用虚函数的语法?

在类体外定义虚函数的语法是什么?

class random{

public:
   random(int i = 0);
   virtual ~random(){};
   virtual void print() const;
protected:
   int id;      

};
Run Code Online (Sandbox Code Playgroud)

是吗?

virtual void random::print() {


}
Run Code Online (Sandbox Code Playgroud)

c++ virtual-functions class

1
推荐指数
1
解决办法
1984
查看次数

WinApi 控件未显示在主窗口上

你好 我有以下 win32 程序,我有一个EDITTEXT没有显示在屏幕上的控件。EDITTEXT在主窗口上画了两个控件,但只有一个显示,这是为什么?

完整代码

#include <windows.h>
#include <iostream>
#include "resource.h"
using namespace std;
const int BUFFERMAX = 512;
char server_ip[BUFFERMAX];
int port;


const char windclassname[] = "windowClass";

LRESULT CALLBACK WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
INT_PTR CALLBACK AboutDialog(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
INT_PTR CALLBACK ConnectWin(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);


int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow){
    WNDCLASSEX parent_window;
    HWND hwnd;
    MSG msg;

    parent_window.cbSize = sizeof(WNDCLASSEX);
    parent_window.style = 0;
    parent_window.lpfnWndProc = WndProc;
    parent_window.cbClsExtra = 0;
    parent_window.cbWndExtra = …
Run Code Online (Sandbox Code Playgroud)

c++ winapi controls

1
推荐指数
1
解决办法
503
查看次数

使用php进行简单的登录实现 (清除会话以便在您注销时点击"返回"不起作用)

我有一个简单的登录系统与PHP会话.我遇到的问题是即使在点击"注销"后,我仍然可以通过点击后退按钮返回到上一页.

我退出的方式由以下方式完成......

<?php
session_start(); 

session_unset();  
session_destroy();

header("Location: ./login.php"); // redirect to login page.

?>
Run Code Online (Sandbox Code Playgroud)

如何完全删除会话..?

php cookies session login session-cookies

1
推荐指数
1
解决办法
417
查看次数

友谊和运营商重载帮助

我有以下课程

#ifndef Container_H
#define Container_H
#include <iostream>
using namespace std;

class Container{

    friend bool operator==(const Container &rhs,const Container &lhs);
 public:
   void display(ostream & out) const;

 private:
   int sizeC;                // size of Container
   int capacityC;            // capacity of dynamic array
   int * elements;            // pntr to dynamic array
  };
ostream & operator<< (ostream & out, const Container & aCont);
#endif
Run Code Online (Sandbox Code Playgroud)

和这个源文件

#include "container.h"

/*----------------------------*********************************************
note: to test whether capacityC and sizeC are equal, must i add 1 to sizeC?
seeing as …
Run Code Online (Sandbox Code Playgroud)

c++ arrays containers class friend

0
推荐指数
1
解决办法
155
查看次数

在参数和继承中定义参数值

我在使用某些Java时遇到问题,如何在Java中提供默认参数值?例如我在C ++中有这个

DVD(int i, string t, int y, string d="Unknown"): Items(i,t,y),director(d){} 在Java中,我尝试

public Dvd(int i, String t,int y, String d="Unknown"){
        super(i,t,y);
        director = d;
    }
Run Code Online (Sandbox Code Playgroud)

无法建立。那么我该如何提供默认值呢?

在我的主要测试课程中,我尝试给出3个参数,分别为4,但这也失败了。我如何解决这个问题?

java multiple-inheritance default-value

0
推荐指数
1
解决办法
272
查看次数

模板功能错误

我有一个函数,它接受一个名为"Triple"的类的参数,并返回float类型的3个值的averge.

template <typename ElemT>
float average(Triple ElemT<float> &arg){
    float pos1 = arg.getElem(1);
    float pos2 = arg.getElem(2);
    float pos3 = arg.getElem(3);

    return ( (pos1+pos2+po3) /3 );
}
Run Code Online (Sandbox Code Playgroud)

当我尝试编译这个我得到

q2b.cpp:32: error: template declaration of `float average'
q2b.cpp:32: error: missing template arguments before "ElemT"
Run Code Online (Sandbox Code Playgroud)

不太清楚这意味着什么.

c++ gcc templates class

0
推荐指数
1
解决办法
1312
查看次数

确定真/假

以下代码

#include <iostream>
using namespace std;

int main(){
    char greeting[50] = "goodmorning everyone";
    char *s1 = greeting;
    char *s2 = &greeting[7];

    bool test = s2-s1;

    cout << "s1 is: " << s1 << endl;
    cout << "s2 is: " << s2 << endl;
    if (test == true ){
        cout << "test is true and is: " << test << endl;
    }

    if (test == false){
        cout<< "test is false and is: " << test << endl;
    }

    return 0;
} …
Run Code Online (Sandbox Code Playgroud)

c++ gcc boolean

0
推荐指数
2
解决办法
386
查看次数

将图像文件存储到缓冲区(gif,jpeg等).

我正在尝试将图像文件加载到缓冲区中以便通过scket发送它.我遇到的问题是程序创建一个有效大小的缓冲区,但它不会将整个文件复制到缓冲区中.我的代码如下

//imgload.cpp
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

int main(int argc,char *argv){

    FILE *f = NULL;
    char filename[80];
    char *buffer = NULL;
    long file_bytes = 0;
    char c = '\0';
    int i = 0;

    printf("-Enter a file to open:");
    gets(filename);

    f = fopen(filename,"rb");
    if (f == NULL){
        printf("\nError opening file.\n");
    }else{
        fseek(f,0,SEEK_END);
        file_bytes = ftell(f);
        fseek(f,0,SEEK_SET);

        buffer = new char[file_bytes+10];

    }

    if (buffer != NULL){
        printf("-%d + 10 bytes allocated\n",file_bytes);
    }else{
        printf("-Could not allocate memory\n");
        // Call …
Run Code Online (Sandbox Code Playgroud)

c++ file-io bufferedimage image

0
推荐指数
1
解决办法
5558
查看次数