Hello, I am working on a small library of *useful* (kinda) functions that add to c++, This is mainly for me, as i'm too lazy to write long functions to do a simple task like printing a new line.
I have these three files :
Header :
Code:
implementation :
Code:
& demo program :
Code:
when I compile with clang++ main.cpp -std=c++19 -o main.exe
i get these errors :
Code:
what am I doing wrong?
I have these three files :
Header :
Code:
///////////////////////////////////////
// Name : C-Flat header
// Author : izder456
// License : Simplified 2-Clause BSD
// Version : a0.1
// Lauguage : C++ header
///////////////////////////////////////
namespace N
{
class c-flat
{
public:
//newline function
void coutln();
//length function of string
int lens(char* s);
};
};
implementation :
Code:
///////////////////////////////////////
// Name : C-Flat library
// Author : izder456
// License : Simplified 2-Clause BSD
// Version : a0.1
// Lauguage : C++
///////////////////////////////////////
#include <math.h>
#include <stdio.h>
#include <iostream>
#include <cstddef>
#include <type_traits>
#include "cf.h" // header in local directory
#include <iostream> // header in standard library
using namespace std;
using namespace N;
//newline function
void c-flat::coutln() {
cout << endl;
}
//length function of string
int c-flat::lens(char * s) {
char * t;
int size = 0;
for (t = s; *t != '\0'; t++) {
size++;
};
return size;
}
& demo program :
Code:
///////////////////////////////////////
// Name : C-Flat example program
// Author : izder456
// License : Simplified 2-Clause BSD
// Version : a0.1
// Lauguage : C++ header
///////////////////////////////////////
#include <math.h>
#include <stdio.h>
#include <iostream>
#include <cstddef>
#include <type_traits>
#include "cf.h"
#include <iostream>
using namespace N;
int main() {
c-flat cf;
printf("line 1");
cf.coutln();
printf("line 3");
}
when I compile with clang++ main.cpp -std=c++19 -o main.exe
i get these errors :
Code:
In file included from main.cpp:14:
./cf.h:11:9: error: expected unqualified-id
class c-flat
^
main.cpp:19:3: error: expected unqualified-id
c-flat cf;
^
main.cpp:21:2: error: use of undeclared identifier 'cf'
cf.coutln();
^
3 errors generated.
what am I doing wrong?