Talk:Criticism of C++

From Wikipedia, the free encyclopedia

This article is not well recherched and requires serious rework before merged. 85.88.24.15 (talk)

The topic "Criticism of C++" is a requested article on wiki. Hence an effort has to be made to start somewhere so that it can be revamped by experts once the work gets started. Aandu (talk) 08:38, 26 December 2007 (UTC)

The following Topics need to be elaborated upon:

  No Dynamic type safety  
  Criticism of features that break Object Orientation
  Standardization drive 
  Maintenance
  Economy of expression
  Tools for mitigating issues with C.... Aandu (talk) 08:46, 26 December 2007 (UTC)

Let me add a topic for elaboration: In my experience, compared to C, C++ programs tend to end up vastly more bloated, overly-complex, and hard to follow. This seems to be from a proclivity towards major over-and-mis-use of Object Oriented programming as a universal panacea, where every stupid little thing becomes an elaborate class. Discuss. —Preceding unsigned comment added by 24.18.201.182 (talk) 11:43, 29 December 2007 (UTC)

[edit] syntax for range

There is really syntax for range.

example:

#include<cstdio>
unsigned int n;
int main(){
scanf("%u",&n);
switch(n){
case 0:
puts("This is zero");
break;
case 1 ... 9:
puts("It has one digit");
break;
case 10 ... 99:
puts("It has two digits");
break;
default:
puts("It has more than three digits");
}
return 0;
}

The above is not valid C++. I think the ranges in a case statement (1...99) is an extension of the GNU/GCC compiler. 195.14.207.109 (talk) 15:33, 3 June 2008 (UTC)

[edit] function as parameter

This is an example using a function as a parameter

#include<cstdio>

void swap(int&a,int&b){
        int c=a;
        a=b;
        b=c;
}

void sort(int*arr,int n,bool cmp(int,int)){
        for(int i=0;i<n-1;i++)
                for(int j=i;j>=0;j--)
                        if(cmp(arr[j+1],arr[j]))
                                swap(arr[j],arr[j+1]);
}

bool reverse(int a,int b){
        return a>b;
}

int main(){
        int list[]={1,2,3,4,5};
        sort(list,5,reverse);
        for(int i=0;i<5;i++)
                printf("%d\n",list[i]);
        return 0;
}

The 3rd parameter of sort(int*,int,bool(int,int)) is really a function. —Preceding unsigned comment added by Michaeldadmum (talkcontribs) 13:00, 12 January 2008 (UTC)

In the above sort function, "bool cmp(int,int)" is invalid. It has to be a function pointer. 195.14.207.109 (talk) 15:33, 3 June 2008 (UTC)