Object Oriented programing
#include
class string
{
char str[20];
public:
string();
void operator+(string &);
void operator>>(istream &);
void operator<<(ostream &);
};
string::string()
{
}
void string::operator + (string &s)
{
cout << strcat (str,s.str);
}
void string::operator>>(istream &din)
{
din>>str;
}
void string::operator<<(ostream &dout)
{
dout<
}
void main()
{
string s1,s2;
cout <<"Please enter a string"<
cout <<"Please enter second string"<
s1+s2;
}
Now for some Ruby work
#!/usr/bin/ruby
a='harshad'
b='joshi'
c=a+b
print"c"
Job over. Isent Ruby more cool??
Why do Indian engineering institutes and colleges prefer more of C++, when many good options are available?
3 Comments:
If the work involves just concatenation of two strings then any of ruby, shell, perl, python scripts could be used. But in real industry the work is much more than concatenating 2 strings. If you're part of the industry already you wouldn't have posted this blog, if you're not you'll learn sooner or later. You could use java instead of c++ if you wish.
Is this joke?
#include <iostream>
#include <string>
int main() {
std::string a = "John";
std::string b = "Doe";
std::cout << a << b << std::endl;
return 0;
}
I agree Ruby is cool. Scripting languages are not scalable when used as part of the embedded systems (atleast not for now). They have their own overheads.
Post a Comment
<< Home