| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 411 人关注过本帖
标题:怎么调用一个编好的类
取消只看楼主 加入收藏
夜闯杏花村
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2009-9-29
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:2 
怎么调用一个编好的类
我编了一个没有main方法的类,然后在另一个工程里面调用了这个.h文件,并且生成了一些这个类的对象,但是在编译的时候老是说找不到这个.h文件怎么回事啊?
搜索更多相关主题的帖子: 工程 
2009-09-29 14:36
夜闯杏花村
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2009-9-29
收藏
得分:0 

#include<iostream>
using namespace std;
class date
{
private:
    int year;
    int month;
    int day;
    int f;
    int g;
    int N;
public:
    void readIn(void)
    {
        int year1;
        int month1;
        int day1;
        cout<<"&Ccedil;&euml;&Ecirc;&auml;&Egrave;&euml;&Egrave;&Otilde;&AElig;&Uacute;"<<endl;
        cout<<"year=";
        cin>>year1;
        cout<<endl;
        cout<<"month=";
        cin>>month1;
        cout<<endl;
        cout<<"day=";
        cin>>day1;
        cout<<endl;
        if(year1>0)
            year=year1;
        else
        {
            cout<<"&Egrave;&Otilde;&AElig;&Uacute;&cedil;&ntilde;&Ecirc;&frac12;&Ecirc;&auml;&Egrave;&euml;&Oacute;&ETH;&Icirc;ó&pound;&not;&Ccedil;&euml;&Ecirc;&auml;&Egrave;&euml;(Y)&Ouml;&Oslash;&ETH;&Acirc;&sup2;&acirc;&Ecirc;&Ocirc;&raquo;ò&Ecirc;&auml;&Egrave;&euml;(N)&frac12;á&Ecirc;&oslash;&sup3;&Igrave;&ETH;ò"<<endl;
            char decision;
            cin>>decision;
            switch(toupper(decision))
            {
            case 'Y':
                    readIn();
            case 'N':
                {
                    cout<<"&sup3;&Igrave;&ETH;ò&frac12;á&Ecirc;&oslash;"<<endl;
                    system("pause");
                    exit(0);
                }
            }
        }
        if(month1>0&&month1<=12)
            month=month1;
        else
        {
            cout<<"&Egrave;&Otilde;&AElig;&Uacute;&cedil;&ntilde;&Ecirc;&frac12;&Ecirc;&auml;&Egrave;&euml;&Oacute;&ETH;&Icirc;ó&pound;&not;&Ccedil;&euml;&Ecirc;&auml;&Egrave;&euml;(Y)&Ouml;&Oslash;&ETH;&Acirc;&sup2;&acirc;&Ecirc;&Ocirc;&raquo;ò&Ecirc;&auml;&Egrave;&euml;(N)&frac12;á&Ecirc;&oslash;&sup3;&Igrave;&ETH;ò"<<endl;
            char decision;
            cin>>decision;
            switch(toupper(decision))
            {
            case 'Y':
                    readIn();
            case 'N':
                {
                    cout<<"&sup3;&Igrave;&ETH;ò&frac12;á&Ecirc;&oslash;"<<endl;
                    system("pause");
                    exit(0);
                }
            }
        }
        if((month==1||month==3||month==5||month==7||month==8||month==10||month==12)&&(day1>0&&day1<=31))
            day=day1;
        else if((month==4||month==6||month==9||month==11)&&(day1>0&&day1<=30))
            day=day1;
        else if((month==2)&&(year%400!=0&&year%4==0)&&(day1>0)&&(day1<=28))
            day=day1;
        else if((month=2)&&(year%4!=0)&&(day1>0&&day1<=29))
            day=day1;
        else
        {
            cout<<"&Egrave;&Otilde;&AElig;&Uacute;&cedil;&ntilde;&Ecirc;&frac12;&Ecirc;&auml;&Egrave;&euml;&Oacute;&ETH;&Icirc;ó&pound;&not;&Ccedil;&euml;&Ecirc;&auml;&Egrave;&euml;(Y)&Ouml;&Oslash;&ETH;&Acirc;&sup2;&acirc;&Ecirc;&Ocirc;&raquo;ò&Ecirc;&auml;&Egrave;&euml;(N)&frac12;á&Ecirc;&oslash;&sup3;&Igrave;&ETH;ò"<<endl;
            char decision;
            cin>>decision;
            switch(toupper(decision))
            {
            case 'Y':
                    readIn();
            case 'N':
                {
                    cout<<"&sup3;&Igrave;&ETH;ò&frac12;á&Ecirc;&oslash;"<<endl;
                    system("pause");
                    exit(0);
                }
            }
        }
    }
    int getYear()
    {
        return year;
    }
    int getMonth()
    {
        return month;
    }
    int getDay()
    {
        return day;
    }
 
    int methodF(int Y,int M)//&frac14;&AElig;&Euml;&atilde;f&micro;&Auml;·&frac12;·¨&pound;&not;&AElig;&auml;&Ouml;&ETH;Y&acute;ú±í&Auml;ê&pound;&not;M&acute;ú±í&Ocirc;&Acirc;
    {
        if(M<3)
            f=Y-1;
        else if(month>=3)
            f=Y;
        return f;
    }
    int methodG(int m)//&frac14;&AElig;&Euml;&atilde;g&micro;&Auml;&ordm;&macr;&Ecirc;&yacute;&pound;&not;&AElig;&auml;&Ouml;&ETH;m&acute;ú±í&Ocirc;&Acirc;
    {
        if(month<3)
            g=m+3;
        else if(month>=3)
            f=m+1;
            return g;
    }
    int methodN(int n1,int n2, int n3)//&frac14;&AElig;&Euml;&atilde;N&micro;&Auml;&ordm;&macr;&Ecirc;&yacute;&pound;&not;&AElig;&auml;&Ouml;&ETH;n1&acute;ú±íf&pound;&not;n2&acute;ú±íg
    {
        N=1461*n1/4+153*n2/5+n3;
        return N;
    }
};
这个是我建好的类
然后在另一个工程里面调用这个类创造对象和调用方法
#include<iostream>
#include<minu.h>
void apply()
{
    minu date1;
    minu date2;
}
int sub(int a,int b)
{
    return (a-b);
}
void loop()
{
    cout<<"&Ecirc;&auml;&Egrave;&euml;(Y)&frac14;&Igrave;&ETH;&oslash;&sup2;&acirc;&Ntilde;é&raquo;ò&Otilde;&szlig;&Ecirc;&auml;&Egrave;&euml;(N)&frac12;á&Ecirc;&oslash;&sup3;&Igrave;&ETH;ò";
    int decision;
    cin>>decision;
    switch(toupper(decision))
    {
        case 'Y':
            {
                apply();
                date1.readIn();
                date2.readIn();
                int sub;
                sub=sub(date1.methodN-date2.methodN);
                cout<<date1.getYear()<<" "<<date1.getMonth()<<" "<<date1.getDay()<<" "<<"&Oacute;&euml;"<<date2.getYear()<<" "<<date2.getMonth()<<" "<<
                        date2.getDay()<<"&Iuml;à&sup2;&icirc;"<<sub<<"&Igrave;ì"<<endl;
            }
        case 'N':
            {
                cout<<"&sup3;&Igrave;&ETH;ò&frac12;á&Ecirc;&oslash;"<<endl;
            }
 
 
int main(void)
{
    apply();
    date1.readIn();
    date2.readIn();
    int sub;
    sub=sub(date1.methodN-date2.methodN);
    cout<<date1.getYear()<<" "<<date1.getMonth()<<" "<<date1.getDay()<<" "<<"&Oacute;&euml;"<<date2.getYear()<<" "<<date2.getMonth()<<" "<<
        date2.getDay()<<"&Iuml;à&sup2;&icirc;"<<sub<<"&Igrave;ì"<<endl;
    loop();
    system(pause);
    return 0;
}
但是老实说找不到上面的那个类...
 
         
 
 
 
 
2009-09-30 13:33
夜闯杏花村
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2009-9-29
收藏
得分:0 
哦,我试试啊
谢啦
2009-09-30 19:47
快速回复:怎么调用一个编好的类
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.032640 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved