假设我定义了两个不相关的类型和两个具有相同签名但类型过滤器不同的扩展方法:publicclassFoo{}publicclassBar{}publicstaticclassFooExtensions{publicstaticTFooFrob(thisTFoofoo)whereTFoo:Foo{}publicstaticTFooBrob(thisTFoofoo)whereTFoo:Foo{}}publicstaticclassBarExtensions{publicstaticTBarFrob(thisTBarbar)whereTBar:Bar{}}然后当我写newFoo().Frob(
请查看此代码段。我知道这没有多大意义,只是为了说明我遇到的问题:#includeusingnamespacestd;structtBar{templatevoidPrintDataAndAddress(constT&thing){cout(thing);}private://friendstructtFoo;//fixesthecompilationerrortemplatevoidPrintAddress(constT&thing){cout(consttFoo&);private:intmData=42;};structtWidget{intmData=666;};intmain(
请查看此代码段。我知道这没有多大意义,只是为了说明我遇到的问题:#includeusingnamespacestd;structtBar{templatevoidPrintDataAndAddress(constT&thing){cout(thing);}private://friendstructtFoo;//fixesthecompilationerrortemplatevoidPrintAddress(constT&thing){cout(consttFoo&);private:intmData=42;};structtWidget{intmData=666;};intmain(