为什么找不到函数重载?

时间:2018-07-27 10:49:59

标签: c++ inheritance final overloading

很抱歉,如果它是重复的或愚蠢的问题。

但是我无法编译以下c ++代码; (VS2017更新15.7.5)

export default class Article extends Component{
    handlesubmit(e)
    {
        e.preventDefault();
        const data = new FormData(e.target);
        let userid=qs.parseUrl(window.location.search).query.id;
        data.append("userid",userid);
        if(document.cookie.split(';')[0]=='login=true')
        fetch('/api/medium/article',{
            method: 'POST',
            body:data
        })
        .then(Response=>{
            console.log(Response);
            return Response.json();
        })
        .then(Response=>{
            console.log(Response);
            window.location.pathname='/medium';
            return Response;
        })
        .catch(err=>{
            return err;
        });
        else{
            alert("please login again");
            window.location.pathname='/medium';
        }
    }
    render()
    {
        return (
            <div className="create-article">
                <form encType="multipart/form-data" className="articleCreating" onSubmit={this.handlesubmit} >

                    <div className="form-group">
                        <select className="custom-select" autoFocus required name='category'>
                            <option value="">Select Category</option>
                            <option value="TECHNOLOGY">Technology</option>
                            <option value="NATURE">Nature</option>
                            <option value="FOOD">Food</option>
                        </select>
                    </div>

                    <div className="input-group">
                        <input type="text" className="form-control" aria-label="Title" placeholder="Title"
                        maxLength="70" spellCheck="true" name="title" required />
                    </div>

                    <div className="input-group">
                        <input type="text" className="form-control" aria-label="Subtitle" placeholder="Subtitle" 
                        spellCheck="true" name="description" required />
                    </div>

                    <div className="input-group has-error">
                        <textarea className="form-control" aria-label="With textarea" placeholder="Description" cols="10"
                        rows="10" spellCheck="true" name="article" required>
                        </textarea>
                    </div>

                    <div className="fileinput">
                        <span><input type="file" name="image"/></span>
                    </div>
                    <div className="article-submit">
                       <button className="btn btn-raised btn-success" type='submit'>Create Article</button>
                    </div>
                </form>
            </div>

        )
    }
}

最后一行class IInterface { public: virtual void FnX(int) = 0; virtual void FnX(int, int) = 0; virtual void FnY(int) = 0; }; class CClassBase : public IInterface { public: virtual void FnX(int) override {} virtual void FnX(int, int) override final {} virtual void FnY(int) override final {} }; class CClassX : public CClassBase { public: virtual void FnX(int) override {} }; void Foo() { CClassX x; x.FnY(1); x.FnX(2); static_cast<CClassBase &>(x).FnX(3, 4); static_cast<IInterface &>(x).FnX(5, 6); x.FnX(7, 8); } 无法编译。 编译错误:

  

错误C2660:'CClassX :: FnX':函数没有2个参数

谁能解释一下,为什么它不编译?还是为什么找不到函数重载x.FnX(7, 8);

0 个答案:

没有答案