小编use*_*036的帖子

2个类之间的双向关联

我想在两个类之间创建双向关联.例如,class A具有class B私有属性并class B具有class A其私有属性.

我得到的错误主要是:

Error   323 error C2653: 'Account' : is not a class or namespace name   
Error   324 error C2143: syntax error : missing ';' before '{'
Run Code Online (Sandbox Code Playgroud)

(我收到这样的错误)

我相信这些错误与我在account.h中包含paymentMode.h的方式有关,反之亦然.我尝试在其中一个类中评论一个包含,并且工作正常.请问如何删除此类错误,同时我仍然可以在帐户和paymentMode类之间建立双向关联?

谢谢!

附上我编写的代码.

    //paymentMode.h

    #pragma once
    #ifndef _PAYMENTMODE_H
    #define _PAYMENTMODE_H

    #include <string>
    #include <iostream>
    #include <vector>
    #include "item.h"
    #include "account.h"

    using namespace std;

    class PaymentMode
    {
    private:
        string paymentModeName;
        double paymentModeThreshold;
        double paymentModeBalance; //how much has the user spent using this …
Run Code Online (Sandbox Code Playgroud)

c++ visual-c++ visual-studio-2012

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

使用mci发送字符串C++播放MP3

我正在尝试在我正在做的一个项目中播放一些 mp3 文件作为背景音乐。我尝试使用 mcisendstring 播放它,但它无法工作:(

这些是我所做的:

CMP3_MCI myMp3;
std::string address= "C:\\Users\\music embed testing\\test.mp3";
myMp3.Load(address);
myMp3.Play();
Run Code Online (Sandbox Code Playgroud)

//加载函数

void Load(string szFileName)
{
    m_szFileName = szFileName;
    Load2();
}
Run Code Online (Sandbox Code Playgroud)

//加载2函数

void Load2()
{
      std::string szCommand = "open \"" + GetFileName() + "\" type mpegvideo alias " + GetFileName();       
       mciSendString(szCommand.c_str(), NULL, 0, 0);
}
Run Code Online (Sandbox Code Playgroud)

//播放函数

void Play()
{
    std::string szCommand = "play " + GetFileName() + " from 0";
    mciSendString(szCommand.c_str(), NULL, 0, 0);
}
Run Code Online (Sandbox Code Playgroud)

//getFileName 基本上返回存储为私有属性的 m_szFileName

c++ clr mci visual-c++

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

标签 统计

c++ ×2

visual-c++ ×2

clr ×1

mci ×1

visual-studio-2012 ×1