• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

Some feedback about C++

(oO (||||) (||||) Oo)
Loyal Member
Joined
Aug 6, 2009
Messages
2,132
Reaction score
429
So before I started college I wanted to get a hang of C++ programming. Syntax was easy and general code writing was piece of cake, but when you get into objects, pointers, arrays it get's too complicated and you simply give up. That's what I did.

Well now that I am taking CS in college, and this is only week 3, I can say that it has been the most progressive week in learning c++ programming. Why?

When you get into a CS class a professor will set a requirments for your labs/assignments. For example my class we are not allowed to use string or vector, and simply can't use stdio library.

Well crap, how do you output a string? How do you keep a list of objects? This is when you actually learn. What I am saying is, when you have to implement your own objects instead of using premade ones you get the experience or the feel from it. For example here is my implementation of string using char array. It's not perfect in any way but it makes my job easier later when working on the lab.

Code:
#pragma once#include <iostream>
#include <cstring>


class String
{
	public:
		// Overloading cout <<
		friend std::ostream& operator<<(std::ostream& output, const String& s)
		{
			if (s.string != NULL)
				output << s.string;
			return output;
		}


		// Overloading cin >>
		friend std::istream& operator>>(std::istream& input, String& s)
		{
			char temp[255];
			input.get(temp, sizeof(temp)-1, '\n');
			s.SetString(temp);
			return input;
		}


		String operator=(String& s)
		{
			this->SetString(s.string);
			return *this;
		}


		bool operator != (String s) const
		{
			return ( strcmp(string, s.string)!=0 ) ? true : false;
		}


		bool operator == (String s) const
		{
			return ( strcmp(string, s.string)==0 ) ? true : false;
		}


		String(void)
		{
			string = NULL;
		}


		String(char data[])
		{
			string = new char[strlen(data) + 1];
			strcpy(string, data);
		}
		~String(void)
		{
			
		}


		bool Compare(char data[])
		{
			return (std::strcmp(string, data) == 0) ? true : false;
		}


		char* GetString()
		{
			return string;
		}


		void SetString(char data[])
		{
			if (string != NULL)
			{
				delete [] string;
			}
			string = new char[strlen(data) + 1];
			strcpy(string, data);
		}


	private:
		char *string;
};

So if you wanna learn or get a feel of actually learning, just attend CS courses at college near you.

Disclaimer: You might, or might not agree with what I wrote. It's your choice and my choice to state my opinion.
 
Skilled Illusionist
Joined
Nov 21, 2012
Messages
390
Reaction score
213
Or learn C first.

I don't see how learning a different language would help with learning C++. If you're going to learn a language, it'd make more sense to just learn the language. I mean, the only purpose I'd see in someone learning an alternative language first would be if they needed that language as well.. since it's easier to pick up a different language after you learn another one first.

Damn, I just read over that, and I must say.. it wasn't my best wording.
 
Ginger by design.
Loyal Member
Joined
Feb 15, 2007
Messages
2,340
Reaction score
653
I don't see how learning a different language would help with learning C++. If you're going to learn a language, it'd make more sense to just learn the language. I mean, the only purpose I'd see in someone learning an alternative language first would be if they needed that language as well.. since it's easier to pick up a different language after you learn another one first.

Damn, I just read over that, and I must say.. it wasn't my best wording.

C++ is a superset of C. But the strict subset of good features in C++ is also a superset of C.

The STL is something better avoided by most, as are libraries that make extensive use of templates and abusive inheritance semantics (like boost). C++ has a lot of capabilities that aren't value-adds but produce (if used correctly) much more legible code at the cost of the potential for a legible line of code to have many possible meanings, which means one needs to be extremely careful and limit themselves to avoiding certain types of abusive notation. There are also some major issues with new/delete in C++.

You can do everything you can do with C++ in C, but with the downside of needing to drop some type safety (or implementing type checks explicitly), which is why it makes more sense to learn C first. It's the same base language, and you don't NEED anything in C++.
 
Skilled Illusionist
Joined
Nov 21, 2012
Messages
390
Reaction score
213
C++ is a superset of C. But the strict subset of good features in C++ is also a superset of C.

The STL is something better avoided by most, as are libraries that make extensive use of templates and abusive inheritance semantics (like boost). C++ has a lot of capabilities that aren't value-adds but produce (if used correctly) much more legible code at the cost of the potential for a legible line of code to have many possible meanings, which means one needs to be extremely careful and limit themselves to avoiding certain types of abusive notation. There are also some major issues with new/delete in C++.

You can do everything you can do with C++ in C, but with the downside of needing to drop some type safety (or implementing type checks explicitly), which is why it makes more sense to learn C first. It's the same base language, and you don't NEED anything in C++.

jM2.me - Some feedback about C++ - RaGEZONE Forums


Thanks for that explanation MerliN.
 
Skilled Illusionist
Joined
Nov 21, 2012
Messages
390
Reaction score
213
Which is a waste of time.

Dude, read the posts before randomly submitting your own opinion. jMerliN, the all-mighty programming Guru; has spoken.

C++ is a superset of C. But the strict subset of good features in C++ is also a superset of C.

The STL is something better avoided by most, as are libraries that make extensive use of templates and abusive inheritance semantics (like boost). C++ has a lot of capabilities that aren't value-adds but produce (if used correctly) much more legible code at the cost of the potential for a legible line of code to have many possible meanings, which means one needs to be extremely careful and limit themselves to avoiding certain types of abusive notation. There are also some major issues with new/delete in C++.

You can do everything you can do with C++ in C, but with the downside of needing to drop some type safety (or implementing type checks explicitly), which is why it makes more sense to learn C first. It's the same base language, and you don't NEED anything in C++.
 
Back
Top