Error 1 Error C2724
resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and reference Dev centers Retired content Samples We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. C/C++ Building Reference C/C++ Build Errors Compiler Errors C2700 Through C2799 Compiler Errors C2700 Through C2799 Compiler Error C2724 Compiler Error C2724 Compiler Error C2724 Compiler Error C2700 Compiler Error C2701 Compiler Error C2702 Compiler Error C2703 Compiler Error C2704 Compiler Error C2705 Compiler Error C2706 Compiler Error C2707 Compiler Error C2708 Compiler Error C2709 Compiler Error C2710 Compiler Error C2711 Compiler Error C2712 Compiler Error C2713 Compiler Error C2714 Compiler Error C2715 Compiler Error C2718 Compiler Error C2719 Compiler Error C2720 Compiler Error C2721 Compiler Error C2722 Compiler Error C2723 Compiler Error C2724 Compiler Error C2725 Compiler Error C2726 Compiler Error C2728 Compiler Error C2730 Compiler Error C2731 Compiler Error C2732 Compiler Error C2733 Compiler Error C2734 Compiler Error C2735 Compiler Error C2736 Compiler Error C2738 Compiler Error C2739 Compiler Error C2743 Compiler Error C2745 Compiler Error C2748 Compiler Error C2749 Compiler Error C2750 Compiler Error C2751 Compiler Error C2752 Compiler Error C2753 Compiler Error C2754 Compiler Error C2755 Compiler Error C2756 Compiler Error C2757 Compiler Error C2758 Compiler Error C2760 Compiler Error C2761 Compiler Error C2762 Compiler Error C2764 Compiler Error C2765 Compiler Error C2766 Compiler Error C2767 Compiler Error C2768 Compiler Error C2770 Compiler Error C2771 Compiler Error C2773 Compiler Error C2774 Compiler Error C2775 Compiler Error C2776 Compiler Error C2777 Compiler Error C2778 Compiler Error C2779 Compiler Error C2780 Compiler Error C2781 Compiler Error C2782 Compiler Error C2783 Compiler Error C2784 Compiler Error C2785 Compiler Error C2786 Compiler Error C2787 Compiler Error C2788 Compiler Error C2790 Compiler Error C2791 Compiler Error C2792 Compiler Error C2793 Compiler Error C2794 Compiler Error C2795 Compiler Error C2797 Compiler Error C2798 TOC Collapse the table of content Expand the table of content This documentation is archived and i
rectangle of course) and I have a static function attached to it for testing intersections. Now I tried the following: 1
2
3
static int Rect::intersects(Rect& a, Rect& b){ return !(a.x > b.x+(b.width-1) || a.x+(a.width-1) < b.x || a.y > b.y+(b.height-1) || a.y+(a.height-1) < b.y); } And it threw the following error (in Visual Studio here folks): 1
2
1>Rect.cpp 1>c:\documents and settings\aaron\my documents\cpp\of_prerelease_v0.05_windows_vs_fat\of_prerelease_v0.05_windows_vs_fat\app\breakout\engine\rect.cpp(22) : error C2724: 'Rect::intersects' : 'static' should not be used on member functions defined at file scope Does this mean I can't use the type Rect in any static function extending from Rect then? It's https://msdn.microsoft.com/en-us/library/907sf777.aspx a tad annoying because I find it easier to read having a function test two members than one comparing itself to another, plus I'd rather not clutter up my scope and keep these random functions tied to the class they're about. Apr 29, 2008 at 12:12am UTC InLight (47) Remove static. From what I see you don't need it here. In c++ static means 'create only 1 instance' or in the http://www.cplusplus.com/forum/beginner/1667/ case of functions 'can handle static members and variables' - unless your Rect &a and b are static, there is no reason your function should be. Last edited on Apr 29, 2008 at 12:18am UTC Apr 29, 2008 at 7:31am UTC st33d (3) Yes but I'm used to using the static keyword to add a scope to a function. In the above instance, (unless I'm mistaken) if I lose the static keyword I have to create an instance of Rect to operate a function that applies to two other Rects. Which is a bit silly. Bit silly you might counter to refer to two other Rects statically from a Rect, but it allows me to put a function that only works on Rects in the Rect class file. Yes I could write a function in there separate, but then I've got a possible namespace issue. Sticking inside Rect just seems a lot tidier. And I can do this in every other language it seems except C++. How do I get this functionality back into my C++ work? Apr 29, 2008 at 9:44am UTC Faldrax (324) 'static' can indeed be used in C++ to do what you want - to create a Static Member Function. The compiler message is actually telli
error messages. Tweet Most popular tags programming languages visual c++ compile time error messages programming-languages visual-c compile-time-error-messages java mysql dbms runtime-error-messages http://www.errorbase.net/2055/error-c2724-identifier-static-should-not-be-used-on-member-functions-defined-at-file-scope Photoshop oracle netbeans nudge photoshop mosek rasterize subversion php sql vector http://c.bigresource.com/C-Error-Using-this-pointer-in-Static-Members-Function--xDCZ1qTv.html data svn facebook tomcat latex apache visual sap phpmyadmin runtime error messages c type layer windows eclipse-svn-subversion-java photos pool paypal sqlserver driver commit rsa 2010 adobe-premiere-pro c# jquery javascript firebug lyx asp memory-leaks Error C2724: (identifier) : (static) should not be used on member functions error 1 defined at file scope +1 vote Static member functions should be declared with external linkage. Ex: class C {
static void func();
};
static void C::func(){}; // C2724 compile-time-error-messages programming-languages visual-c requested 5 years ago by errorbase (170,010 points) edited 5 years ago by onur 1 Solution 0 votes Possible resolution: class C {
error 1 error static void func();
};
void C::func(){}; solved 5 years ago by errorbase (170,010 points) edited 5 years ago by onur Related errors +1 vote 1 solution Error C3842: (function): (const) and (volatile) qualifiers on member functions of managed types are not supported requested 5 years ago by errorbase (170,010 points) compile-time-error-messages programming-languages visual-c 0 votes 1 solution Error C3417: (member) : value types cannot contain user-defined special member functions requested 5 years ago by errorbase (170,010 points) compile-time-error-messages programming-languages visual-c +1 vote 1 solution Error C2598: linkage specification must be at global scope requested 5 years ago by errorbase (170,010 points) compile-time-error-messages programming-languages visual-c 0 votes 1 solution Error C2487: (identifier) : member of dll interface class may not be declared with dll interface requested 5 years ago by errorbase (170,010 points) compile-time-error-messages programming-languages visual-c 0 votes 1 solution Error C2129: static function (function) declared but not defined requested 5 years ago by errorbase (170,010 points) compile-time-error-messages programming-languages visual-c Send feedback Powered by Question2Answer
#include